MySQL连接数

查看数据库连接数

1
2
3
4
5
6
7
8
9
mysql> show status like 'Thread%';
+-------------------+--------+
| Variable_name | Value |
+-------------------+--------+
| Threads_cached | 3 |
| Threads_connected | 153 |
| Threads_created | 216859 |
| Threads_running | 2 |
+-------------------+--------+
  • Threads_connected: 打开的连接数
  • Threads_running: 激活的连接数
1
2
3
4
5
6
mysql> show variables like '%max_connections%';
+-----------------+-------+
| Variable_name | Value |
+-----------------+-------+
| max_connections | 2000 |
+-----------------+-------+
  • max_connections: 最大连接数

设置数据库连接数

修改my.cnf配置文件:
1
2
[mysqld]
max_connections = 2000
修改mysql变量:
1
mysql> set global max_connections=2000;