MySQL常用命令总结

# 查看最大连接数

show variables like 'max_connections';

#  临时修改
set GLOBAL max_connections=200;

# 永久修改
max_connections=200  # 修改配置文件

 

# 查看主从同步状态

show slave status\G

 

#  连接相关状态和变量

mysql> show status like '%connect%';
+-----------------------------------------------+---------------------+
| Variable_name                                 | Value               |
+-----------------------------------------------+---------------------+
| Aborted_connects                              | 18                  |
| Connection_errors_accept                      | 0                   |
| Connection_errors_internal                    | 0                   |
| Connection_errors_max_connections             | 3261                |
| Connection_errors_peer_address                | 0                   |
| Connection_errors_select                      | 0                   |
| Connection_errors_tcpwrap                     | 0                   |
| Connections                                   | 43887383            |
| Locked_connects                               | 0                   |
| Max_used_connections                          | 152                 |
| Max_used_connections_time                     | 2019-07-10 04:01:29 |
| Performance_schema_session_connect_attrs_lost | 0                   |
| Ssl_client_connects                           | 0                   |
| Ssl_connect_renegotiates                      | 0                   |
| Ssl_finished_connects                         | 0                   |
| Threads_connected                             | 62                  |
+-----------------------------------------------+---------------------+
16 rows in set (0.00 sec)


Connection_errors_max_connections:当MySQL的最大并发连接数超过设置的max_connections变量的值,被拒绝的次数会记录到这个状态值里。 这个状态值过高,有可能是系统并发较高,可以考虑调大max_connections。

Connections: MySQL服务从初始化开始成功建立连接的数量,该值不断累加。
Max_used_connections: MySQL服务从启动开始,同一时刻并发连接的最大值,如果该值很大,则有可能系统并发较高,可以考虑调大max_connections。
Threads_connected: 当前打开的连接数量。

 

 # 查看当前执行sql

select  *  from    information_schema.processlist\G

 

posted @ 2019-07-25 15:07  LiShiChao  阅读(188)  评论(0编辑  收藏  举报