下面小編就為大家帶來一篇mysql連線數設定操作方法(Too many connections)。小編覺得蠻不錯的,現在就分享給大家,也給大家做個參考。一起跟著小編過來看看吧
mysql在使用過程中,發現連線數超了~~~~
[root@linux-node1 ~]# mysql -u glance -h 192.168.1.17 -p Enter password: ERROR 1040 (08004): Too many connections
解決辦法,這也是centos7下修改mysql連線數的做法:
1)暫時修改
MariaDB [(none)]> show variables like "max_connections"; +-----------------+-------+ | Variable_name | Value | +-----------------+-------+ | max_connections | 214 | +-----------------+-------+ 1 row in set (0.00 sec) MariaDB [(none)]> set GLOBAL max_connections=1000; Query OK, 0 rows affected (0.00 sec) MariaDB [(none)]> show variables like "max_connections"; +-----------------+-------+ | Variable_name | Value | +-----------------+-------+ | max_connections | 1000 | +-----------------+-------+ 1 row in set (0.00 sec)
2)永久修改:
配置/etc/my.cnf
[mysqld]新新增一行如下參數:
max_connections=1000
重新啟動mariadb服務,再次查看mariadb資料庫最大連線數,可以看到最大連線數是214,並非我們設定的1000。
MariaDB [(none)]> show variables like 'max_connections'; +-----------------+-------+ | Variable_name | Value | +-----------------+-------+ | max_connections | 214 | +-----------------+-------+
這是由於mariadb有預設開啟檔案數限制。可以透過設定/usr/lib/systemd/system/mariadb.service來調大開啟檔案數目。
設定/usr/lib/systemd/system/mariadb.service
[Service]新新增兩行如下參數:
LimitNO FILE =10000 LimitNPROC=10000
重新載入系統服務,並重新啟動mariadb服務
systemctl --system daemon-reload systemctl restart mariadb.service
再次查看mariadb資料庫最大連線數,可以看到最大連線數已經是1000
MariaDB [(none)]> show variables like 'max_connections'; +-----------------+-------+ | Variable_name | Value | +-----------------+-------+ | max_connections | 1000 | +-----------------+-------+
以上是詳細介紹mysql連線數設定操作方法(Too many connections)的詳細內容。更多資訊請關注PHP中文網其他相關文章!