mysql

mysql 链接数不够异常

2019-03-26  本文已影响0人  良人与我

通过工具连接mysql 或者 启动web程序报 没有足够链接错误
Data source rejected establishment of connection, message from server: "Too many connections"
是因为mysql的连接数配置的太少,修改配置解决此问题。
查看 mysqld 位置

[root@bogon mysql]# which mysqld           
/usr/sbin/mysqld

查看配置文件位置

[root@bogon mysql]# /usr/sbin/mysqld --verbose --help | grep -A 1 "Default options"
2019-03-26 11:26:11 0 [Warning] Insecure configuration for --secure-file-priv: Location is accessible to all OS users. Consider choosing a different directory.
2019-03-26 11:26:11 0 [Note] /usr/sbin/mysqld (mysqld 5.6.41) starting as process 17941 ...
2019-03-26 11:26:11 17941 [Note] Plugin 'FEDERATED' is disabled.
Default options are read from the following files in the given order:
/etc/my.cnf /etc/mysql/my.cnf /usr/etc/my.cnf ~/.my.cnf 
2019-03-26 11:26:11 17941 [Note] Binlog end
2019-03-26 11:26:11 17941 [Note] Shutting down plugin 'MyISAM'
2019-03-26 11:26:11 17941 [Note] Shutting down plugin 'CSV'

编辑配置文件 添加如下配置

vim /etc/my.cnf
[mysqld]
max_connections=1000

重新启动 服务

service mysqld restart

查看链接数状态

mysql> show processlist;
+-------+---------+-----------------------+---------+---------+------+-------+------------------+
| Id    | User    | Host                  | db      | Command | Time | State | Info             |
+-------+---------+-----------------------+---------+---------+------+-------+------------------+
|  9844 | root    | 192.168.130.78:54377  | topspeed | Sleep   |   34 |       | NULL             |
|  9855 | root    | 192.168.130.78:54857  | topspeed | Sleep   | 2226 |       | NULL             |
|  9935 | athena | 192.168.130.34:43330  | athena | Sleep   | 4527 |       | NULL             |
|  9936 | athena | 192.168.130.34:43332  | athena | Sleep   | 4527 |       | NULL             |
|  9937 | athena | 192.168.130.34:43334  | athena | Sleep   | 4527 |       | NULL             |
|  9938 | athena | 192.168.130.34:43336  | athena | Sleep   | 4527 |       | NULL             |
|  9939 | athena | 192.168.130.34:43338  | athena | Sleep   | 4527 |       | NULL             |
|  9940 | athena | 192.168.130.34:43340  | athena | Sleep   | 4527 |       | NULL             |
|  9941 | athena | 192.168.130.34:43342  | athena | Sleep   | 4527 |       | NULL             |
上一篇 下一篇

猜你喜欢

热点阅读