如何获取MySQL帮助信息(二)

2014-11-24 17:13:38 · 作者: · 浏览: 1
able_type,engine from information_schema.tables;
| setup_timers | BASE TABLE | PERFORMANCE_SCHEMA |
| threads | BASE TABLE | PERFORMANCE_SCHEMA |
| animals | BASE TABLE | InnoDB |
| shop | BASE TABLE | InnoDB |
+----------------------------------------------+-------------+--------------------+
92 rows in set (0.02 sec)


mysql> pager; --查看当前的pager设置
PAGER set to 'tail -5'
mysql> nopager; --切换到标准(缺省)pager方式
PAGER set to stdout


--tee命令,输出日志文件
mysql> tee /tmp/query.log --开启输出到文件,相当与SQL*plus下的spool
Logging to file '/tmp/query.log'
mysql> select table_name,table_type,engine from information_schema.tables;
+----------------------------------------------+-------------+--------------------+
| table_name | table_type | engine |
+----------------------------------------------+-------------+--------------------+
| CHARACTER_SETS | SYSTEM VIEW | MEMORY |
| COLLATIONS | SYSTEM VIEW | MEMORY |
.............
mysql> notee; --关闭输出到文件,相当于SQL*Plus下的spool off
Outfile disabled.
mysql> system tail /tmp/query.log --查看输出的日志文件
| setup_consumers | BASE TABLE | PERFORMANCE_SCHEMA |
| setup_instruments | BASE TABLE | PERFORMANCE_SCHEMA |
| setup_timers | BASE TABLE | PERFORMANCE_SCHEMA |
| threads | BASE TABLE | PERFORMANCE_SCHEMA |
| animals | BASE TABLE | InnoDB |
| shop | BASE TABLE | InnoDB |
+----------------------------------------------+-------------+--------------------+
92 rows in set (0.02 sec)


--改变mysql提示符
mysql> prompt SessionA>
PROMPT set to 'SessionA> '


--恢复到缺省提示符
SessionA> prompt;
Returning to default PROMPT of mysql>


--执行sql脚本文件
mysql> system more query.sql --注意,此时为当前目录
use chardb
select * from tb_isam;
mysql> source query.sql
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
+------+-------+
| id | value |
+------+-------+
| 1 | a |
| 2 | b |
| 3 | c |
| 4 | f |
+------+-------+
4 rows in set (0.00 sec)


--获取状态信息
mysql> status;
--------------
mysql Ver 14.14 Distrib 5.5.37, for Linux (x86_64) using readline 5.1


Connection id: 6
Current database: chardb
Current user: root@localhost
SSL: Not in use
Current pager: less
Using outfile: ''
Using delimiter: ;
Server version: 5.5.37-log MySQL Community Server (GPL)
Protocol version: 10
Connection: Localhost via UNIX socket
Server characterset: latin1
Db characterset: utf8
Client characterset: latin1
Conn. characterset: latin1
UNIX socket: /var/lib/mysql/mysql.sock
Uptime: 3 hours 10 min 59 sec


Threads: 1 Questions: 97 Slow queries: 0 Opens: 313 Flush tables: 1 Open tables: 51 Queries per second avg: 0.008
--------------


--修改客户端字符集
mysql> charset gbk;
Charset changed
mysql> \s
--------------
mysql Ver 14.14 Distrib 5.5.37, for Linux (x86_64) using readline 5.1


Connection id: 6
Current database: chardb
Current user: root@localhost
SSL: Not in use
Current pager: less
Using outfile: ''
Using delimiter: ;
Server version: 5.5.37-log MySQL Community Serv