如何增加 MySQL 连接数(max_connections)?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/22297773/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to increase MySQL connections(max_connections)?
提问by shekhar
Every socket of MySQL Database will have defaults connections as 100 but I am looking for any way to increase the number of possible connections > 100 to a socket connection of MySQL Database.
MySQL 数据库的每个套接字的默认连接数为 100,但我正在寻找任何方法将可能的连接数增加 > 100 到 MySQL 数据库的套接字连接。
回答by Abdul Manaf
If you need to increase MySQL Connections without MySQL restart do like below
如果您需要在不重启 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)
These settings will change at MySQL Restart.
这些设置将在 MySQL 重启时更改。
For permanent changes add below line in my.cnf and restart MySQL
对于永久性更改,在 my.cnf 中添加以下行并重新启动 MySQL
max_connections = 150
回答by Rahul Tripathi
From Increase MySQL connection limit:-
MySQL's default configuration sets the maximum simultaneous connections to 100. If you need to increase it, you can do it fairly easily:
MySQL 的默认配置将最大同时连接数设置为 100。如果你需要增加它,你可以很容易地做到:
For MySQL 3.x:
对于 MySQL 3.x:
# vi /etc/my.cnf
set-variable = max_connections = 250
For MySQL 4.x and 5.x:
对于 MySQL 4.x 和 5.x:
# vi /etc/my.cnf
max_connections = 250
Restart MySQL once you've made the changes and verify with:
进行更改后重新启动 MySQL 并使用以下命令进行验证:
echo "show variables like 'max_connections';" | mysql
EDIT:-(From comments)
编辑:-(来自评论)
The maximum concurrent connection can be maximum range: 4,294,967,295. Check MYSQL docs
最大并发连接数可以是最大范围: 4,294,967,295。检查MYSQL 文档
回答by Guillaume
I had the same issue and I resolved it with MySQL workbench, as shown in the attached screenshot:
我遇到了同样的问题,我用 MySQL 工作台解决了它,如附加的屏幕截图所示:
- in the navigator (on the left side), under the section "management", click on "Status and System variables",
- then choose "system variables" (tab at the top),
- then search for "connection" in the search field,
- and 5. you will see two fields that need to be adjusted to fit your needs (max_connections and mysqlx_max_connections).
- 在导航器(左侧)中,在“管理”部分下,单击“状态和系统变量”,
- 然后选择“系统变量”(顶部的选项卡),
- 然后在搜索栏中搜索“连接”,
- 和 5. 您将看到需要调整以满足您的需要的两个字段(max_connections 和 mysqlx_max_connections)。
Hope that helps!
希望有帮助!