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

#!/bin/bash

case $ in
crm) cmd='mysql -h192.168.1.2 -uroot -proot -P3306 -Dcrm'
;;
*)
echo "数据库变量不存在:$1 仅支持输入 crm"
exit
;;
esac
shift
$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 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

mysql --prompt的更多相关文章

  1. mysql -prompt选项

    使用-pormpt修改提示符.可以在登录时或者在登录后使用prompt选项来修改提示符 (1)使用mysql命令行参数修改提示符 # mysql -u root -p Enter password: ...

  2. [转] mysql --prompt介绍

    mysql --prompt修改命令行链接mysql时的提示符,shell脚本示例如下 #!/bin/bash case $1 in crm) cmd='mysql -h192.168.1.2 -ur ...

  3. (转)mysql -prompt选项

    mysql -prompt选项 原文:http://www.cnblogs.com/abclife/p/5632826.html 使用-pormpt修改提示符.可以在登录时或者在登录后使用prompt ...

  4. mysql prompt的用法详解

    prompt命令可以在mysql提示符中显示当前用户.数据库.时间等信息 代码如下: mysql -uroot -p --prompt="\\u@\\h:\\d \\r:\\m:\\s> ...

  5. MySQL prompt命令

    修改提示符,设置后挺方便的 例如: 几个好用的参数 \d 当前数据库 \u 当前用户 \h 当前主机 更多参数可以参考mysol官方文档 参考文档:https://dev.mysql.com/doc/ ...

  6. MySQL prompt提示符总结

      A counter that increments for each statement you issue \D 当前日期 \d 当前数据库 \h 数据库主机 \l The current de ...

  7. prompt更改MySQL登陆后的提示符

    临时生效 mysql> prompt \u@standby \r:\m:\s > PROMPT set to '\u@standby \r:\m:\s >' root@standby ...

  8. MySQL的prompt不生效的问题

    安装完MySQL之后,使用了自定义的配置文件来启动MySQL,发现配置在[mysql]中的prompt并没有生效 [root@MySQL56_L1 ~]# /usr/local/mysql/bin/m ...

  9. MySQL碎碎念

    1. 如何修改Mysql的用户密码 mysql> update mysql.user set password=password('hello') where user='root'; mysq ...

随机推荐

  1. angularjs 作用域

    1.指令属性取值:通过attr.someAttribute属性名字获取 以下,通过$eval(attr.data)获取value <div ng-controller="personC ...

  2. Spring知识点总结大全(1)

    1.Spring的分层结构 1.Presentation layer(表示层) (1) 表示逻辑(生成界面代码) (2) 接收请求 (3) 处理业务层抛出的异常 (4) 负责规则验证(数据格式,数据非 ...

  3. 使用Application Insights 做分析

    Application Insights on Windows Desktop apps, services and worker roles : https://azure.microsoft.co ...

  4. 1306. Sorting Algorithm 2016 12 30

    1306. Sorting Algorithm Constraints Time Limit: 1 secs, Memory Limit: 32 MB Description One of the f ...

  5. JS-offsetParent定位父节点

    offsetParent:离当前元素最激动呢一个有定位的父节点 如果没有定位父级,默认是body IE7以下如果当前元素没有定位默认是body,如果有定位就是html IE7以下,如果当前元素的某个父 ...

  6. SA: 情感分析资源(Corpus、Dictionary)

    先主要摘自一篇中文Survey,http://wenku.baidu.com/view/0c33af946bec0975f465e277.html   4.2 情感分析的资源建设 4.2.1 情感分析 ...

  7. XAF 官方问题笔记

    1.How to print report direct, and print preview via an simple action? 如何通过一个按钮直接打印报表或者打印预览报表 https:/ ...

  8. tesseract-ocr 提高验证码识别率手段之---识别码库训练方法

    本文是对tesseract-ocr 使用的进一步技术升级说明,使用默认的识别库识别率比较低怎么办? 不用着急,tesseract-ocr本身的工具中提供了使用你提供的素材进行人工修正以提高识别率的方法 ...

  9. java-IO

    框架图 IO(Input Output)流IO流用来处理设备之间的数据传输,Java对数据的操作是通过流的方式,用于操作流的对象都在IO包中. 流按操作数据分为两种:字节流与字符流 .流按流向分为:输 ...

  10. eclipse中输入中文为繁体

    http://blog.163.com/guomaolin_gavin/blog/static/199618307201218104452930/ eclipse中输入中文为繁体! 2012-02-0 ...