Mysql-too-many-connections错误

Mysql-too-many-connections错误

查看最大连接数

1
2
3
4
5
6
7
8
9
10
11
12
mysql> show variables like '%max_connections%';
+-----------------+-------+
| Variable_name | Value |
+-----------------+-------+
| max_connections | 151 |
+-----------------+-------+
1 row in set (0.00 sec)

###修改连接数
set global max_connections = 1000;
vi /etc/my.cnf
max_connections=1000

查看实时连接数

1
2
3
4
5
6
7
8
9
10
11
12
13
mysql> show status like 'Threads%';
+-------------------+-------+
| Variable_name | Value |
+-------------------+-------+
| Threads_cached | 1 |
| Threads_connected | 2 | ###这个数值指的是打开的连接数
| Threads_created | 3 |
| Threads_running | 2 | ###这个数值指的是激活的连接数,这个数值一般远低于connected数值
+-------------------+-------+
4 rows in set (0.03 sec)

show processlist;
show status like 'Threads%';

查看timeout

1
2
3
4
5
show variables like '%timeout';

## 设置timeout
set global wait_timeout=300;
set global interactive_timeout=500;