(转)mysql -prompt选项
mysql -prompt选项
原文:http://www.cnblogs.com/abclife/p/5632826.html
使用-pormpt修改提示符。可以在登录时或者在登录后使用prompt选项来修改提示符
(1)使用mysql命令行参数修改提示符
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
# mysql -u root -pEnter password:Welcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 27Server version: 5.6.25 Source distributionCopyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.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 28Server version: 5.6.25 Source distributionCopyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.#切换数据库root@localhost:(none) 10:05:25>use testReading table information for completion of table and column namesYou can turn off this feature to get a quicker startup with -ADatabase changedroot@localhost:test 10:05:31> |
(2)修改配置文件/etc/my.cnf
|
1
2
|
[mysql]prompt="\\u@\\h:\\d \\r:\\m:\\s>" |
(3)在 MySQL 中使用 prompt 命令
|
1
2
3
4
5
|
mysql> prompt \r:\m:\s\P>\_PROMPT set to \'\r:\m:\s\P>\_\'08:20:42pm> promptReturning to default PROMPT of mysql>mysql> |
(4)当然可以在在Bash层修改 MYSQL_PS1变量
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
# export MYSQL_PS1="(\u@\h) [\d]> "# mysql -u root -pEnter password:Welcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 31Server version: 5.6.25 Source distributionCopyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.(root@localhost) [(none)]> use testReading table information for completion of table and column namesYou can turn off this feature to get a quicker startup with -ADatabase 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 |
\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 |
\ |
|
(转)mysql -prompt选项的更多相关文章
- mysql -prompt选项
使用-pormpt修改提示符.可以在登录时或者在登录后使用prompt选项来修改提示符 (1)使用mysql命令行参数修改提示符 # mysql -u root -p Enter password: ...
- mysql --prompt
mysql --prompt修改命令行链接mysql时的提示符,shell脚本示例如下 #!/bin/bash in crm) cmd='mysql -h192.168.1.2 -uroot -pro ...
- [转] mysql --prompt介绍
mysql --prompt修改命令行链接mysql时的提示符,shell脚本示例如下 #!/bin/bash case $1 in crm) cmd='mysql -h192.168.1.2 -ur ...
- mysql prompt的用法详解
prompt命令可以在mysql提示符中显示当前用户.数据库.时间等信息 代码如下: mysql -uroot -p --prompt="\\u@\\h:\\d \\r:\\m:\\s> ...
- MySQL binlog-do-db选项是危险的
很多人通过 binlog-do-db, binlog-ignore-db, replicate-do-db 和 replicate-ignore-db 来过滤复制(某些数据库), 尽管有些使用, ...
- MySQL binlog-do-db选项是危险的[转]
很多人通过 binlog-do-db, binlog-ignore-db, replicate-do-db 和 replicate-ignore-db 来过滤复制(某些数据库), 尽管有些使用, ...
- 监控mysql各种选项
安装mysql之后,需要对mysql服务进行监控. nagios开源自带的check_mysql 对 mysql 的slave 机监控倒是不错.但是对数据库主机监控就略显不足了. 使用一个监控 ...
- MySQL read_only选项的作用
1作用: 从字面意思上看就可以知道这个是把mysql设置为只读,但是这个只读只是针对一般用户而言的,对于root这种用super权限的用户read_only是没有用的. 2设置方式: set glob ...
- MySQL prompt命令
修改提示符,设置后挺方便的 例如: 几个好用的参数 \d 当前数据库 \u 当前用户 \h 当前主机 更多参数可以参考mysol官方文档 参考文档:https://dev.mysql.com/doc/ ...
随机推荐
- C++友元函数、友元类
1.什么是友元函数? 友元函数就是可以直接访问类的成员(包括私有数据)的非成员函数,也就是说他并不属于这个类,他是一种外部的函数. 一个外部函数只能通过类的授权成为这个类友元函数,这就涉及到一个关键字 ...
- 检查路径是否存在与创建指定路径(mfc)
检查路径是否存在 if (access("D:\\Work\\Encryption\\DES", 0)) 为真,则路径不存在 创建指定路径 system("md D:\\ ...
- Linux 基础教程 28-nc命令
nc nc命名netcat,直译为网络猫.在CentOS 7查看帮助的解释如下所示: ncat - Concatenate and redirect sockets 翻译过来就是可以连接和重定 ...
- Centos环境下手动设置-网络参数配置-网络挨排错顺序-设置网卡为上网模式的设定
Linux中网络参数大致包含以下内容: IP地址 子网掩码 网关 DNS服务器 主机名(默认 localhost) 历来Linux系统中修改这些参数的方式通常有:命令.文件两种.其中通过命令设置可以立 ...
- Android-MediaRecorder录像机(视频)
在上一篇博客,Android-MediaRecorder录制音频,中讲解了使用Android API MediaRecorder 刻录音频,这篇博客主要是介绍 使用MediaRecorder刻录(视频 ...
- [C#]如何解决修改注册表受限问题(转)
在项目中添加一个Application Manifest File,名字默认为app.manifest,内容中应该有一行: <requestedExecutionLevellevel=" ...
- Hibernate4获取Connection,ResultSet对象
项目中需要一个json对象,封装的时候,需要数据的列名. 在jdbc里面,可以有个ResultMetaData对象获取列名字.因为我用的是hibernate,这个框架已经封装了很多,一般是难以获得re ...
- Apache commons StringUtils 在运行时出现NoClassDefError错误的解决方法
Apache commons StringUtils 在运行时出现NoClassDefError错误的解决方法 在用tomcat运行WEB项目,并且使用了StringUtils包的时候,会出现 jav ...
- 关于类属性值校验的一点记录 【知识点Attribute】
好久没有进来了,之前励志坚持写博客,记录自己在做代码搬运工这段历程中点滴,可是仅仅只坚持了几天,就放弃了!果然是,世上无难事,只要肯放弃!哈哈……闲话不多说,开始进入正题,给自己留点笔记,避免将来老了 ...
- MvvmLight框架使用入门(三)
本篇是MvvmLight框架使用入门的第三篇.从本篇开始,所有代码将通过Windows 10的Universal App来演示.我们将创建一个Universal App并应用MvvmLight框架. ...