mysql问题-“Too many connections”
线上程序报了个错:
com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException:
Data source rejected establishment of connection, message from server: "Too many connections"
mysql> show variables like 'max_connections';
+-----------------+-------+
| Variable_name | Value |
+-----------------+-------+
| max_connections | 151 |
+-----------------+-------+
1 row in set
修改默认最大连接数
mysql> set global max_connections=1000;
Query OK, 0 rows affected
mysql> show variables like '%max_connections%';
+-----------------+-------+
| Variable_name | Value |
+-----------------+-------+
| max_connections | 1000 |
+-----------------+-------+
但这种方式在mysql服务重启之后就不生效了,最好在MySQL配置文件my.ini 或 my.cnf的参数max_connections,将其改为max_connections=1000
,然后重启MySQL即可