(转)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 -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
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> prompt Returning 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 -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 |
\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/ ...
随机推荐
- RocketMQ服务器监控误区
请不要监控10912端口 case: result: 监控10912端口会导致HAService异常,新起线程,吃掉内存,无限次监控虚拟机将宕机! 时间上是直接因果关系. 监控10911 和 9876 ...
- Linux 基础教程 28-nc命令
nc nc命名netcat,直译为网络猫.在CentOS 7查看帮助的解释如下所示: ncat - Concatenate and redirect sockets 翻译过来就是可以连接和重定 ...
- ubuntu解压文件命令大全
ubuntu 下rar解压工具安装方法: 压缩功能 安装 sudo apt-get install rar 卸载 sudo apt-get remove rar 解压功能 安装 sudo apt-ge ...
- View Pi's Status on WebBrowser
1. install php and cgi support sudo apt-get install php5-common sudo apt-get install php5-cgi sudo a ...
- expect+scp传输文件发现文件丢失
背景 使用expect+scp去跨机器传输文件,(别问我为什么,因为公司的测试机器都是通过堡垒机的,无法绕开堡垒机,只能暂时使用这个方法了),结果发现从A传递到B的tar.gz文件大小不一致了的,当时 ...
- 网络正常只有自己访问网站异常一度让你怀疑,是不是被黑了!域名解析异常是如何发生的,如何解决处理及C#编程实现一键修改Hosts文件
首先大家要知道在浏览器上浏览虚拟主机,必须使用Hosts文件或域名系统(DNS)实现主机名到IP地址的解析.在局域网中用Hosts文件或DNS都可以,在Internet上只能用DNS了. 1.当用户输 ...
- 「BZOJ4318」OSU!
题目链接 戳我 \(Solution\) 我们考虑每增加一个\(1\)会对答案有什么影响: \[E((x+1)^3)-E(x^3)=E(3x^2+3x+1)=3E(x^2)+3E(x)+1\] 所以我 ...
- 201621123023《Java程序设计》第10周学习总结
一.本周学习总结 1.1 以你喜欢的方式(思维导图或其他)归纳总结集合与泛型相关内容. 二.书面作业 本次PTA作业题集异常 1. 常用异常 结合题集题目7-1回答 1.1 自己以前编写的代码中经常出 ...
- GO学习笔记 - 包内首字母大写的名称是被导出的,才能被其它包代码调用!
在GO语言的任意包内,如果名称的首字母是大写的,意味着这个名称被导出,在其它包中可以使用“包名.名称”方式来调用,如果名称首字母不是大写,那么只能在这个包内部使用!这个概念还真是和以往接触的编程语言的 ...
- 20165219 Exp1 PC平台逆向破解
20165219 Exp1 PC平台逆向破解 实践目标 本次实践的对象是一个名为pwn1的linux可执行文件. 该程序正常执行流程是:main调用foo函数,foo函数会简单回显任何用户输入的字符串 ...