【发布时间】:2014-03-10 10:32:43
【问题描述】:
MySQL 数据库的每个套接字的默认连接数为 100,但我正在寻找任何方法来增加 MySQL 数据库的套接字连接的可能连接数 > 100。
【问题讨论】:
标签: mysql database sockets database-connection
MySQL 数据库的每个套接字的默认连接数为 100,但我正在寻找任何方法来增加 MySQL 数据库的套接字连接的可能连接数 > 100。
【问题讨论】:
标签: mysql database sockets database-connection
如果您需要在不重启 MySQL 的情况下增加 MySQL 连接数,请执行以下操作
mysql> show variables like 'max_connections';
+-----------------+-------+
| Variable_name | Value |
+-----------------+-------+
| max_connections | 100 |
+-----------------+-------+
1 row in set (0.00 sec)
mysql> SET GLOBAL max_connections = 150;
Query OK, 0 rows affected (0.00 sec)
mysql> show variables like 'max_connections';
+-----------------+-------+
| Variable_name | Value |
+-----------------+-------+
| max_connections | 150 |
+-----------------+-------+
1 row in set (0.00 sec)
这些设置将在 MySQL 重新启动时更改。
对于永久更改,在 my.cnf 中添加以下行并重新启动 MySQL
max_connections = 150
【讨论】:
来自Increase MySQL connection limit:-
MySQL 的默认配置将最大同时连接数设置为 100。如果您需要增加它,您可以相当轻松地做到这一点:
对于 MySQL 3.x:
# vi /etc/my.cnf
set-variable = max_connections = 250
对于 MySQL 4.x 和 5.x:
# vi /etc/my.cnf
max_connections = 250
完成更改后重新启动 MySQL 并通过以下方式验证:
echo "show variables like 'max_connections';" | mysql
编辑:-(来自 cmets)
最大并发连接数可以是最大范围:4,294,967,295。检查MYSQL docs
【讨论】:
Before increasing MySQL’s connection limit, you really owe it to yourself (and your server), to find out why you’re reaching the maximum number of connections. Over 90% of the MySQL servers that are hitting the maximum connection limit have a performance limiting issue that needs to be corrected instead.
我遇到了同样的问题,我用 MySQL 工作台解决了它,如所附屏幕截图所示:
希望有帮助!
【讨论】: