mysq在命令行模式下执行shell命令

mysql可以在命令行模式下执行shell命令

mysql> help

For information about MySQL products and services, visit:
http://www.mysql.com/
For developer information, including the MySQL Reference Manual, visit:
http://dev.mysql.com/
To buy MySQL Enterprise support, training, or other products, visit:
https://shop.mysql.com/

List of all MySQL commands:
Note that all text commands must be first on line and end with ';'
? (?) Synonym for `help'.
clear (c) Clear the current input statement.
connect ( ) Reconnect to the server. Optional arguments are db and host.
delimiter (d) Set statement delimiter.
edit (e) Edit command with $EDITOR.
ego (G) Send command to mysql server, display result vertically.
exit (q) Exit mysql. Same as quit.
go (g) Send command to mysql server.
help (h) Display this help.
nopager ( ) Disable pager, print to stdout.
notee ( ) Don't write into outfile.
pager (P) Set PAGER [to_pager]. Print the query results via PAGER.
print (p) Print current command.
prompt (R) Change your mysql prompt.
quit (q) Quit mysql.
rehash (#) Rebuild completion hash.
source (.) Execute an SQL script file. Takes a file name as an argument.
status (s) Get status information from the server.
system (!) Execute a system shell command.
tee (T) Set outfile [to_outfile]. Append everything into given outfile.
use (u) Use another database. Takes database name as argument.
charset (C) Switch to another charset. Might be needed for processing binlog with multi-byte charsets.
warnings (W) Show warnings after every statement.
nowarning (w) Don't show warnings after every statement.

For server side help, type 'help contents'

mysql> system ls
20171024.txt 20171026.txt derby.log files.txt hello.txt json.scala log1.txt log.txt metastore_db mm.txt name.csv namejson.txt spark-2.2.0-bin-hadoop2.7 tian.txt

mysql> ! ls /var/lib
alternatives  cloud  dhclient  logrotate.status  mlocate      mysql-keyring  ntp       postfix  random-seed  rpm      stateless  yum
authconfig    dbus   games     misc              mysql-files  net-snmp       plymouth  prelink  readahead    rsyslog  udev

---------------------------

mysql> use zqgamedb;
Database changed
mysql> select database();
+------------+
| database() |
+------------+
| zqgamedb   |
+------------+
1 row in set (0.00 sec)

-----------------------

mysql> select user();
+----------------+
| user()         |
+----------------+
| root@localhost |
+----------------+
1 row in set (0.00 sec)

---------------------------

SHOW STATUS   返回服务器状态

-------------

mysql> show processlist;
+------+------+---------------------+----------+---------+-------+----------+------------------+
| Id   | User | Host                | db       | Command | Time  | State    | Info             |
+------+------+---------------------+----------+---------+-------+----------+------------------+
| 1467 | qzls | 10.135.95.201:51967 | mysql    | Sleep   | 13748 |          | NULL             |
| 1471 | qzls | 10.135.95.201:51973 | mysql    | Sleep   | 37468 |          | NULL             |
| 1476 | root | 10.135.95.201:51989 | share    | Sleep   |   876 |          | NULL             |
| 1477 | qzls | 10.135.95.201:51990 | mysql    | Sleep   |   675 |          | NULL             |
| 1522 | qzls | 10.135.95.201:52112 | mysql    | Sleep   |  1064 |          | NULL             |
| 1533 | qzls | 10.135.95.201:52688 | mysql    | Sleep   |  1064 |          | NULL             |
| 1534 | qzls | 10.135.95.201:52781 | mysql    | Sleep   | 13746 |          | NULL             |
| 1552 | root | 10.135.95.201:62999 | share    | Sleep   | 13746 |          | NULL             |
| 1554 | qzls | 10.135.95.201:63559 | mysql    | Sleep   | 32968 |          | NULL             |
| 1567 | root | localhost           | zqgamedb | Sleep   |  7705 |          | NULL             |
| 1568 | root | localhost           | zqgamedb | Query   |     0 | starting | show processlist |
+------+------+---------------------+----------+---------+-------+----------+------------------+

----------------------------

show variables like '%max_connections%'; 查看最大连接数


mysql> show variables like '%max_conn%';
+--------------------+--------+
| Variable_name      | Value  |
+--------------------+--------+
| max_connect_errors | 100000 |
| max_connections    | 2000   |
+--------------------+--------+
2 rows in set (0.00 sec)

----------------------------------------------------------------------

mysql> show status like '%connections%';
+-----------------------------------+---------------------+
| Variable_name                     | Value               |
+-----------------------------------+---------------------+
| Connection_errors_max_connections | 0                   |
| Connections                       | 1569                |
| Max_used_connections              | 74                  |
| Max_used_connections_time         | 2018-07-13 14:22:49 |
+-----------------------------------+---------------------+
4 rows in set (0.00 sec)

Aborted_clients 由于客户没有正确关闭连接已经死掉,已经放弃的连接数量。
Aborted_connects 尝试已经失败的MySQL服务器的连接的次数。
Connections 试图连接MySQL服务器的次数。
Created_tmp_tables 当执行语句时,已经被创造了的隐含临时表的数量。
Delayed_insert_threads 正在使用的延迟插入处理器线程的数量。
Delayed_writes 用INSERT DELAYED写入的行数。
Delayed_errors 用INSERT DELAYED写入的发生某些错误(可能重复键值)的行数。
Flush_commands 执行FLUSH命令的次数。
Handler_delete 请求从一张表中删除行的次数。
Handler_read_first 请求读入表中第一行的次数。
Handler_read_key 请求数字基于键读行。
Handler_read_next 请求读入基于一个键的一行的次数。
Handler_read_rnd 请求读入基于一个固定位置的一行的次数。
Handler_update 请求更新表中一行的次数。
Handler_write 请求向表中插入一行的次数。
Key_blocks_used 用于关键字缓存的块的数量。
Key_read_requests 请求从缓存读入一个键值的次数。
Key_reads 从磁盘物理读入一个键值的次数。
Key_write_requests 请求将一个关键字块写入缓存次数。
Key_writes 将一个键值块物理写入磁盘的次数。
Max_used_connections 同时使用的连接的最大数目。
Not_flushed_key_blocks 在键缓存中已经改变但是还没被清空到磁盘上的键块。
Not_flushed_delayed_rows 在INSERT DELAY队列中等待写入的行的数量。
Open_tables 打开表的数量。
Open_files 打开文件的数量。
Open_streams 打开流的数量(主要用于日志记载)
Opened_tables 已经打开的表的数量。
Questions 发往服务器的查询的数量。
Slow_queries 要花超过long_query_time时间的查询数量。
Threads_connected 当前打开的连接的数量。
Threads_running 不在睡眠的线程数量。
Uptime 服务器工作了多少秒。

原文地址:https://www.cnblogs.com/playforever/p/7929286.html