最近使用Mysql数据库进行多编程操做时报错:ERROR 1040: Too many connections 。提示链接过多,检查发现Mysql的默认链接数为151,可根据实际状况进行修改。mysql
mysql -uroot -p MariaDB [(none)]> show variables like 'max_connections'; +-----------------+-------+ | Variable_name | Value | +-----------------+-------+ | max_connections | 151 | +-----------------+-------+ 1 row in set (0.01 sec)
能够发现实际使用的链接数己达到最大链接数限制sql
MariaDB [(none)]> show global status like 'Max_used_connections'; +----------------------+-------+ | Variable_name | Value | +----------------------+-------+ | Max_used_connections | 152 | +----------------------+-------+ 1 row in set (0.01 sec)
MariaDB [(none)]> set GLOBAL max_connections=4096; Query OK, 0 rows affected (0.00 sec) MariaDB [(none)]> show variables like 'max_connections'; +-----------------+-------+ | Variable_name | Value | +-----------------+-------+ | max_connections | 4096 | +-----------------+-------+ 1 row in set (0.01 sec)
MariaDB [(none)]> show global status like 'Max_used_connections'; +----------------------+-------+ | Variable_name | Value | +----------------------+-------+ | Max_used_connections | 1002 | +----------------------+-------+ 1 row in set (0.01 sec)