[转] mysql --prompt介绍
mysql --prompt修改命令行链接mysql时的提示符,shell脚本示例如下

#!/bin/bash case $1 in
crm) cmd='mysql -h192.168.1.2 -uroot -proot -P3306 -Dcrm'
;;
*)
echo "数据库变量不存在:$1 仅支持输入 crm"
exit 0
;;
esac
shift 1
$cmd --prompt="[\u@\h:\p(\d) \R:\m:\s] mysql>" --default-character-set=utf8 -A "$@"

在命令行输入 db crm 执行效果如下

liuzhao ~ $ db crm
Warning: Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 54706839
Server version: 5.5.40-36.1-log Percona Server (GPL), Release 36.1, Revision 707 Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. [root@192.168.1.2:3306(crm) 16:59:15] mysql>

--prompt选项列表,示例脚本中用到的选项已经标红
\c |
A counter that increments for each statement you issue |
\D |
当前日期 |
\d |
当前数据库 |
\h |
数据库主机 |
\l |
The current delimiter (new in 5.1.12) |
\m |
当前时间(分) |
\n |
A newline character |
\O |
The current month in three-letter format (Jan, Feb, …) |
\o |
The current month in numeric format |
\P |
am/pm |
\p |
The current TCP/IP port or socket file 端口号 |
\R |
当前时间(小时)(0–23) |
\r |
当前时间(小时)(1–12) |
\S |
Semicolon |
\s |
当前时间(秒) |
\t |
A tab character |
\U |
Your full |
\u |
数据库用户名 |
\v |
The server version |
\w |
The current day of the week in three-letter format (Mon, Tue, …) |
\Y |
The current year, four digits |
\y |
The current year, two digits |
\_ |
A space |
\ |
A space (a space follows the backslash) |
\' |
Single quote |
\" |
Double quote |
\\ |
A literal “\” backslash character |
\ |
|
[转] mysql --prompt介绍的更多相关文章
- mysql --prompt
mysql --prompt修改命令行链接mysql时的提示符,shell脚本示例如下 #!/bin/bash in crm) cmd='mysql -h192.168.1.2 -uroot -pro ...
- MySQL 复制介绍及搭建
MySQL复制介绍 MySQL复制就是一台MySQL服务器(slave)从另一台MySQL服务器(master)进行日志的复制然后再解析日志并应用到自身,类似Oracle中的Data Guard. M ...
- mysql -prompt选项
使用-pormpt修改提示符.可以在登录时或者在登录后使用prompt选项来修改提示符 (1)使用mysql命令行参数修改提示符 # mysql -u root -p Enter password: ...
- 第1 章MySQL 基本介绍
第 1 章 MySQL 基本介绍 前言: 作为最为流行的开源数据库软件之一,MySQL 数据库软件已经是广为人知了.但是为了照顾对MySQL还不熟悉的读者,这章我们将对 MySQL 做一个简单的介 ...
- Spotlight on Mysql详细介绍
Spotlight on Mysql详细介绍 by:授客 QQ:1033553122 1. 版本 2. 使用介绍 1) 主页 会话面板 MySQL面板 INNODB面板 存储面板 主机面板 ...
- 三、安装cmake,安装resin ,tars服务,mysql 安装介绍,安装jdk,安装maven,c++ 开发环境安装
三.安装cmake,安装resin 2018年07月01日 21:32:05 youz1976 阅读数:308 开发环境说明: centos7.2 ,最低配置:1核cpu,2G内存,1M带宽 1. ...
- MySQL入门介绍(mysql-8.0.13)
MySQL入门介绍(mysql-8.0.13单机部署) 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 一.MySQL数据库介绍 1>.MySQL是一种开放源代码的关系型数据库 ...
- MySQL主从复制介绍
MySQL主从复制介绍 MySQL数据库的主从复制方案,和使用scp/rsync等命令进行的文件级别复制类似,都是数据的远程传输,只不过MySQL的主从复制是其自带的功能,无需借助第三方工具,而且,M ...
- MySQL管理工具MySQL Utilities — 介绍与安装(1)
MySQL Utilities介绍 MySQL Utilities 提供一组命令行工具用于维护和管理 MySQL 服务器,包括: 管理工具 (克隆.复制.比较.差异.导出.导入) 复制工具 (安装.配 ...
随机推荐
- ios 内存管理总结
在ios 中 项目有两个内存管理方式 第一种,arc 方式,编译器编译时,自动给obj 加上 release 实现要求 1. 设置项目 将 Objective-C Automatic Referen ...
- JAVA 中不错的开源FTP组件:commons-net
第一步:引入jar到pom.xml. <!-- https://mvnrepository.com/artifact/commons-net/commons-net --> <dep ...
- Log4net的不能产生Log文件的问题
[问题] 用如下的步骤应用了Log4Net: 建立了一个公用的项目, 在里面引入了Log4net的Nuget package. 在公用的项目中建立了一个类,加上了Log4net的attribute. ...
- [Algorithm] Binary tree: Level Order Traversal
function Node(val) { return { val, left: null, right: null }; } function Tree() { return { root: nul ...
- Eclipse使用hibernate插件
首先安装好hibernate插件,进入安装界面,输入下载地址http://download.jboss.org/jbosside/updates/stable,点击下载javaee web 以下的hi ...
- Provide your license server administrator with the following information.error code =-42,147
ArcEngine应用程序开发中,许可不必不可少的.一般采取两种方式来获取许可——License控件和AoInitialize类,但今天在VS2010打开程序时,隔一会弹出错误窗口:Provide y ...
- java 从零开始,学习笔记之基础入门<集合>(十六)
集合 集合:将多个元素放入到一个集合对象中去,对应的集合对象就可以用来存储多元素. Collection接口的子接口:Set接口和List接口. Map不是Collection接口的子接口. Coll ...
- Spring-boot加载resources下的文件
加载方式: FileInputStream keyStoreIn = new FileInputStream(ResourceUtils.getFile("classpath:ca/clie ...
- ERROR - Undefined placeholders found in template:
今天发现了一个BUG,在引用其他的包的的时候报错: ERROR - Undefined placeholders found in template: - Template: META-INF/aut ...
- hadoop mahout 算法和API说明
org.apache.mahout.cf.taste.hadoop.item.RecommenderJob.main(args) --input 偏好数据路径,文本文件.格式 userid\t ite ...