如何增加MySQL连接(max_connections)?

时间:2022-01-30 19:38:59

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数据库的套接字连接的数量。

3 个解决方案

#1


63  

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

#2


5  

From Increase MySQL connection limit:-

从增加MySQL连接限制:-

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。和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文档

#3


2  

I had the same issue and I resolved it with MySQL workbench, as shown in the attached screenshot:

我也遇到了同样的问题,我用MySQL workbench解决了,如附件截图所示:

  1. in the navigator (on the left side), under the section "management", click on "Status and System variables",
  2. 在导航器(左侧)中,在“管理”一节中,单击“状态和系统变量”,
  3. then choose "system variables" (tab at the top),
  4. 然后选择“系统变量”(顶部的选项卡),
  5. then search for "connection" in the search field,
  6. 然后在搜索框中搜索“connection”,
  7. and 5. you will see two fields that need to be adjusted to fit your needs (max_connections and mysqlx_max_connections).
  8. 和5。您将看到需要调整两个字段以满足您的需要(max_connections和mysqlx_max_connections)。

Hope that helps!

希望会有帮助!

The system does not allow me to upload pictures, instead please click on this link and you can see my screenshot...

系统不允许我上传图片,请点击这个链接,你可以看到我的截图……

#1


63  

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

#2


5  

From Increase MySQL connection limit:-

从增加MySQL连接限制:-

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。和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文档

#3


2  

I had the same issue and I resolved it with MySQL workbench, as shown in the attached screenshot:

我也遇到了同样的问题,我用MySQL workbench解决了,如附件截图所示:

  1. in the navigator (on the left side), under the section "management", click on "Status and System variables",
  2. 在导航器(左侧)中,在“管理”一节中,单击“状态和系统变量”,
  3. then choose "system variables" (tab at the top),
  4. 然后选择“系统变量”(顶部的选项卡),
  5. then search for "connection" in the search field,
  6. 然后在搜索框中搜索“connection”,
  7. and 5. you will see two fields that need to be adjusted to fit your needs (max_connections and mysqlx_max_connections).
  8. 和5。您将看到需要调整两个字段以满足您的需要(max_connections和mysqlx_max_connections)。

Hope that helps!

希望会有帮助!

The system does not allow me to upload pictures, instead please click on this link and you can see my screenshot...

系统不允许我上传图片,请点击这个链接,你可以看到我的截图……