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)
需要在配置文件中進行修改,否則重啟數據庫后會失效,可以同時修改變量值和配置文件中的變量值