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

#!/bin/bashcase $1 incrm) 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 707Copyright (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 user_name@host_name account name

\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
\x

x, for any “x” not listed above

转载于:https://www.cnblogs.com/lzrabbit/p/4298789.html

mysql --prompt相关推荐

  1. mysql --prompt详解_mysql5.6 prompt的用法详解

    --prompt=name 参数对于做运维的人来说很重要.我们登入mysql数据库后,mysql的提示符只是一个很简单内容 mysql> ,没有其他任何信息.通过--prompt=name可以自 ...

  2. Mysql:mysql 控制台程序的提示符 prompt 字符串设置

    The prompt command reconfigures the default mysql> prompt. The string for defining the prompt can ...

  3. mysql提示符prompt的用法

    随着管理mysql服务器越来越多,同样的mysql>的提示符有可能会让你输入错误的命令到错误的数据库,这时候需要巧用mysql的提示符,这 是我的提示符root@localhost(mysql) ...

  4. mysql防止误操作之prompt命令提示符

    参考官方资料:https://dev.mysql.com/doc/refman/5.7/en/mysql-commands.html 设置prompt主要是方便搞清楚生产系统中登录的是哪个库,哪个用户 ...

  5. MySQL修改提示符(prompt)

    MySQL修改提示符(prompt) export MYSQL_PS1="(\u@\h) [\d]> " prompt (\u@\h) [\d]>\_ prompt ( ...

  6. MYSQL 连接数据库命令收藏

    一.MySQL 连接本地数据库,用户名为"root",密码"123"(注意:"-p"和"123" 之间不能有空格) C: ...

  7. RHEL5(CentOS)下nginx+php+mysql+tomcat+memchached配置全过程(转)

    RHEL5(CentOS)下nginx+php+mysql+tomcat+memchached配置全过程 一.准备工作:SSH,telnet终端中文显示乱码解决办法vi /etc/sysconfig/ ...

  8. mysql etc_mysql etc下my.conf配置详情

    简介 配置mysql  etc下my.conf配置详情如下 [client] port = 3306 socket = /tmp/mysql.sock default-character-set = ...

  9. mysql send-q_MYSQL---初识

    相关概念说明数据库(Database):按照数据结构来组织.存储和管理数据的仓库,它以一定的组织形式存于存储介质上.数据库本身不真正存储数据,真正的数据是放在数据库中的表(table)中的. 数据库管 ...

最新文章

  1. Oracle-数据泵expdp/impdp实操
  2. 【人脸识别】人脸验证算法Joint Bayesian详解及实现(Python版)
  3. ubuntu16.04 apt-get 报错:E: Unable to locate package update(E: Unable to locate package upgrade)(没解决)
  4. 将计算机设置成交换机主机名,CISCO2950交换机的配置(设置密码、IP地址、主机名)...
  5. 100个网络基础必备知识 ,值得收藏!
  6. 哪一类人用苹果手机最多?
  7. 一次性搭建Hadoop高可用集群
  8. linux查找大文件或目录
  9. [转]隐马尔科夫模型HMM
  10. android 表情的正则,Android 手势 正则匹配图片实例代码
  11. java实现5 4 3 2 1递归_递归及递归的使用
  12. 广东女子职业技术学院计算机应用技术,广东女子学院虚拟校园系统的构建与技术实现...
  13. java大作穿越arpg_动作与角色扮演完美结合 精品ARPG游戏盘点
  14. 哈希表——线性探测法、链地址法、查找成功、查找不成功的平均长度
  15. 梦行扫码付(收银台条码支付 微信钱包条码支付 支付宝二维码支付 手机APP钱包支付 PHP扫码支付 )
  16. 吐血分享:QQ群霸屏技术教程2017(维护篇)
  17. 怎样开发鸿蒙系统的输入法,2020华为开发者大会 讯飞输入法携手鸿蒙共创未来...
  18. 一个屌丝程序员的青春(一三八)
  19. Mybatis逆向工程同名表找错数据库的问题
  20. Creo AFX钢结构设计视频教程

热门文章

  1. 【第一季】CH07_FPGA_RunLED创建VIVADO工程实验
  2. C++模拟实现Objective-C协议和代理模式
  3. (译)在Objective-c里面使用property教程
  4. 【转】Hibernate数据过滤
  5. 阿里云实时计算,前世功,今生能!
  6. Caffe SSD Ubuntu16 04 训练自己的数据集
  7. 增强型for和Iterator学习
  8. Shell脚本中的函数、数组
  9. Xcode配置RunScript编译完自动打包ipa
  10. PHP - 如何解决中文乱码