Mysql “Too many connections“ 异常

当Mysql 数据库抛出如下异常

Caused by: com.mysql.cj.exceptions.CJException: Data source rejected establishment of connection,  message from server: "Too many connections"
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423)

意味着超出设置最大连接数了

-- show variables like 'max_connections'  151 
-- show global status like 'Max_used_connections'; 152 
-- set global max_connections=1000;

这是临时解决方案,当mysql 服务重启之后就失效了,

想要永久修改那么得去安装服务器上去修改 mysql 的 mysql.ini 文件 

max_connections=1000

然后重启mysql 

net stop mysql;
net start mysql;

你可能感兴趣的:(mysql,数据库)