How to Solve MySQL / MariaDB Error 1040 “Too Many Connections”
In this article, I’m going to share how to solve MySQL / MariaDB error 1040 “Too Many Connections”.
Table of Contents
Check Connections
Login to your server and enter this command to login to MySQL/MariaDB client:
mysql -u root -pThen run this command to see max connections limit:
SHOW VARIABLES LIKE "max_connections";By default, max connection is 151.
Solution 1
To set new max_connections value, run this command:
SET GLOBAL max_connections=[new maximum number];For example, let’s set max connection to 300:
SET GLOBAL max_connections=300;Solution 2
Open the file /etc/my.cnf to edit with the command:
sudo nano /etc/my.cnfUnder the [mysqld] section add the following line:
[mysqld]
max_connections=300That’s all. Thank you.
Md Obydullah
Software Engineer | Ethical Hacker & Cybersecurity...
Md Obydullah is a software engineer and full stack developer specialist at Laravel, Django, Vue.js, Node.js, Android, Linux Server, and Ethichal Hacking.