使用-pormpt修改提示符。可以在登录时或者在登录后使用prompt选项来修改提示符

(1)使用mysql命令行参数修改提示符

# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 27
Server version: 5.6.25 Source distribution Copyright (c) 2000, 2015, 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. mysql> # mysql -uroot -p --prompt="\\u@\\h:\\d \\r:\\m:\\s>"
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 28
Server version: 5.6.25 Source distribution Copyright (c) 2000, 2015, 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@localhost:(none) 10:05:25>use test
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A Database changed
root@localhost:test 10:05:31>

(2)修改配置文件/etc/my.cnf

[mysql]
prompt="\\u@\\h:\\d \\r:\\m:\\s>"

(3)在 MySQL 中使用 prompt 命令

mysql> prompt \r:\m:\s\P>\_
PROMPT set to \'\r:\m:\s\P>\_\'
08:20:42pm> prompt
Returning to default PROMPT of mysql>
mysql>

(4)当然可以在在Bash层修改 MYSQL_PS1变量

# export MYSQL_PS1="(\u@\h) [\d]> "
# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 31
Server version: 5.6.25 Source distribution Copyright (c) 2000, 2015, 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@localhost) [(none)]> use test
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A Database changed
(root@localhost) [test]>

参数辅助说明

Option Description
\c A counter that increments for each statement you issue
\D The full current date
\d The default database
\h The server host
\l The current delimiter (new in 5.1.12)
\m Minutes of the current time
\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 The current time, in 24-hour military time (0–23)
\r The current time, standard 12-hour time (1–12)
\S Semicolon
\s Seconds of the current time
\t A tab character
\U

Your full user_name@host_name account name

\u Your user name
\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选项

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

  2. mysql --prompt

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

  3. [转] mysql --prompt介绍

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

  4. mysql prompt的用法详解

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

  5. MySQL binlog-do-db选项是危险的

    很多人通过 binlog-do-db, binlog-ignore-db, replicate-do-db 和   replicate-ignore-db 来过滤复制(某些数据库), 尽管有些使用, ...

  6. MySQL binlog-do-db选项是危险的[转]

    很多人通过 binlog-do-db, binlog-ignore-db, replicate-do-db 和   replicate-ignore-db 来过滤复制(某些数据库), 尽管有些使用, ...

  7. 监控mysql各种选项

    安装mysql之后,需要对mysql服务进行监控.   nagios开源自带的check_mysql 对 mysql 的slave 机监控倒是不错.但是对数据库主机监控就略显不足了.   使用一个监控 ...

  8. MySQL read_only选项的作用

    1作用: 从字面意思上看就可以知道这个是把mysql设置为只读,但是这个只读只是针对一般用户而言的,对于root这种用super权限的用户read_only是没有用的. 2设置方式: set glob ...

  9. MySQL prompt命令

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

随机推荐

  1. ThinkPHP 学习笔记 ( 五 ) 数据验证

    根据官网的教程 ( http://www.thinkphp.cn/info/171.html ),数据验证的使用静态定义方式 ( 以 regex 为例 ) 无法验证数据: 而采用动态验证则正常: 控制 ...

  2. 基于LR的HTTP协议接口性能测试脚本实例

    背景介绍 XXX项目性能测试中新增业务场景:XX设备的在线激活,因为存在多用户同时在线激活,故需进行性能测试以确认后台服务器系统在多用并发时功能是否正常,性能指标是否满足规格要求.用户使用场景为用户通 ...

  3. Apche Kafka 的生与死 – failover 机制详解

    Kafka 作为 high throughput 的消息中间件,以其性能,简单和稳定性,成为当前实时流处理框架中的主流的基础组件. 当然在使用 Kafka 中也碰到不少问题,尤其是 failover ...

  4. Delphi 如何操作外部程序的控件(如按钮,文本框,单选按钮等)

    看你要做什么,比较现在网络很流行的QQ.MSN这些软件都屏蔽了,你可能还可以访问一些小软件的这些控制,思路及方案如下(API函数自己去百度查一下)1.得到你要这个窗口的句柄 使用FindWindow2 ...

  5. vimtutor

    ================================================================================ 欢 迎 阅 读 < V I M ...

  6. td的cellIndex属性被style.display改变

    IE7下面td的cellIndex属性,居然会随着style.display='none'的设置而改变,真是太恶心了

  7. Python学习笔记——1——基础知识

    1.1.变量和算法 python语言很类似人类语言,变量不需要定义类型.比如: 整型 字符串类型 数组 Java int a=12 String s="test" String[] ...

  8. GDB多线程调试

    一.多线程调试1. 多线程调试,最重要的几个命令:info threads                        查看当前进程的线程.                              ...

  9. Aptana Studio 3的汉化

    Aptana Studio 3(下面简称Aptana 3)的汉化方法 1.找到这个网站 http://aptana.com/support 2.单击下面的链接 view documentation 在 ...

  10. CodeForce727C. Guess the Array---交互题

    题目链接:http://codeforces.com/contest/727/problem/C 题意:交互题: printf(“? i j\n”); fflush(stdout); 然后scanf( ...