mysql client命令行端的容易忽视的命令
mysql client命令行端的容易忽视的命令
参考:
http://www.mysqlperformanceblog.com/2014/02/27/dba-101-sometimes-forgotten-functionality-mysql-client/
1) prompt 修改提示符
mysql >\R Production >
PROMPT set to 'Production > '
mysql > \R \u@\h [\d]>
PROMPT set to '\u@\h [\d]>'
root@testbox [test]>
2)tee命令,可以将在mysql客户端的操作放到日志文件中
mysql> \T /tmp/tee.log
Logging to file '/tmp/tee.log'
那么所有的操作都会放/tee.log中去
3) mysql> \s>可以看到当前客户端连接的参数,比如
mysql> \s>
--------------
mysql Ver 14.14 Distrib 5.6.15, for Linux (x86_64) using EditLine wrapper
Connection id: 13149
Current database: sakila
Current user: root@localhost
SSL: Not in use
Current pager: stdout
Using outfile: ''
Using delimiter: ;
Server version: 5.6.15-63.0-log Percona Server (GPL), Release 63.0
Protocol version: 10
Connection: 127.0.0.1 via TCP/IP
Server characterset: latin1
Db characterset: latin1
Client characterset: utf8
Conn. characterset: utf8
TCP port: 3306
Uptime: 10 days 23 hours 32 min 57 sec
Threads: 1 Questions: 1203169 Slow queries: 43745 Opens: 626 Flush tables: 1 Open tables: 178 Queries per second avg: 1.268
--------------
4) \c clean命令
清除输入
mysql> SELECT *
-> FROM city
-> \c
mysql>
5) pager命令,将长的语句分页显示
mysql> \P cat > /tmp/voila.log
PAGER set to 'cat > /tmp/voila.log'
mysql> SELECT * FROM city;
600 rows in set (0.01 sec)