最近在用mysql的時候,雙擊表忽然出現1040 too many connection的錯誤,看錯誤的意思是鏈接的人數太多了。mysql
當最大鏈接數比較小時,可能會出現「1040 too many connection」錯誤。sql
一、首先須要重啓MySQL服務,執行命令:spa
[root@iZ23 ~]# service mysql restart.net
或者:rest
[root@iZ23 ~]# service mysqld restartorm
二、登陸mysql,get
[root@iZ23 ~]# mysql -uroot -pit
輸入密碼,回車;io
三、登陸成功後執行如下語句查詢當前的最大鏈接數:form
mysql> select VARIABLE_VALUE from information_schema.GLOBAL_VARIABLES where VARIABLE_NAME='MAX_CONNECTIONS';
+----------------+
| VARIABLE_VALUE |
+----------------+
| 151 |
+----------------+
1 row in set (0.00 sec)
四、執行如下語句修改最大鏈接數:
mysql> set global max_connections = 3600;
Query OK, 0 rows affected (0.00 sec)
好了,再打開表就不會報錯了
補充:升級5.7後報錯
mysql> select VARIABLE_VALUE from information_schema.GLOBAL_VARIABLES where VARIABLE_NAME='MAX_CONNECTIONS';
ERROR 3167 (HY000): The 'INFORMATION_SCHEMA.GLOBAL_VARIABLES' feature is disabled; see the documentation for 'show_compatibility_56'
mysql>
mysql> show variables like '%show_compatibility_56%';
+-----------------------+-------+
| Variable_name | Value |
+-----------------------+-------+
| show_compatibility_56 | OFF |
+-----------------------+-------+
1 row in set (0.00 sec)
mysql>
mysql> set global show_compatibility_56=on;
Query OK, 0 rows affected (0.00 sec)
mysql> show variables like '%show_compatibility_56%';
+-----------------------+-------+
| Variable_name | Value |
+-----------------------+-------+
| show_compatibility_56 | ON |
+-----------------------+-------+
1 row in set (0.00 sec)
mysql> mysql> select * from information_schema.global_status limit 3;