数据库
首页 > 数据库> > mysql设置最大连接数 max_connections

mysql设置最大连接数 max_connections

作者:互联网

mysql 5.7版本的配置文件为:/etc/mysql/mysql.conf.d/mysqld.cnf

查看最大连接数:

mysql> show variables like '%connection%';
+--------------------------+-----------------+
| Variable_name            | Value           |
+--------------------------+-----------------+
| character_set_connection | utf8            |
| collation_connection     | utf8_general_ci |
| max_connections          | 151             |
| max_user_connections     | 0               |
+--------------------------+-----------------+
4 rows in set (0.49 sec)

设置最大连接数

mysql> set GLOBAL max_connections=2000;
Query OK, 0 rows affected (0.00 sec)

mysql> show variables like '%connection%';
+--------------------------+-----------------+
| Variable_name            | Value           |
+--------------------------+-----------------+
| character_set_connection | utf8            |
| collation_connection     | utf8_general_ci |
| max_connections          | 2000            |
| max_user_connections     | 0               |
+--------------------------+-----------------+
4 rows in set (0.00 sec)

需要在配置文件中进行修改,否则重启数据库后会失效,可以同时修改变量值和配置文件中的变量值

 

标签:utf8,set,max,+--------------------------+-----------------+,连接数,connections,mysq
来源: https://www.cnblogs.com/mianbaoshu/p/15324376.html