通過工具連接mysql 或者 啟動web程序報 沒有足夠鏈接錯誤
Data source rejected establishment of connection, message from server: "Too many connections"
是因為mysql的連接數(shù)配置的太少陌兑,修改配置解決此問題。
查看 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
重新啟動 服務(wù)
service mysqld restart
查看鏈接數(shù)狀態(tài)
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 |