Skip to content
标签
欢迎扫码关注公众号

com.mysql.cj.exceptions.CJException: Too many connections

今天更新测试环境服务,启动时报了如下错误:

master - Exception during pool initialization.
java.sql.SQLNonTransientConnectionException: Could not create connection to database server. Attempted reconnect 3 times. Giving up.
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:111)
......
Caused by: com.mysql.cj.exceptions.CJException: Too many connections

通过如下命令查看连接数,发现当前一共有 151 条记录。

sql
SHOW PROCESSLIST;

而 151 正好是 MySQL 5.7 和 8.0 中 max_connections 的默认值。151 表示可以 150 个客户端连接,再加上一个保留给 root 用户的连接。

my.cnf 中添加以下配置即可以调整最大连接数的数量:

ini
[mysqld]
max_connections=500

不过这种方式需要重启 MySQL 才能生效。也可以通过命令动态修改:

sql
SET GLOBAL max_connections = 500;

查看配置是否已修改:

sql
SHOW VARIABLES LIKE 'max_connections';

Page Layout Max Width

Adjust the exact value of the page width of VitePress layout to adapt to different reading needs and screens.

Adjust the maximum width of the page layout
A ranged slider for user to choose and customize their desired width of the maximum width of the page layout can go.

Content Layout Max Width

Adjust the exact value of the document content width of VitePress layout to adapt to different reading needs and screens.

Adjust the maximum width of the content layout
A ranged slider for user to choose and customize their desired width of the maximum width of the content layout can go.