In the world of free software , there are all kinds of apps, from the smallest to the most recognized and trendsetting, such as GIMP , Apache , or MySQL . And since we're talking about the database engine, let's show you how to fix a common error that can occur in some cases: MySQL's "Too many connections" error.
We say that it can happen because we can spend a lot of time using it without that happening, or suddenly it can happen that if our server has a lot of demand we see the error message very soon, which to be more precise says mysqli_connect(): (HY000/1040): Too many connections.
By default, MySQL allows a maximum of 100 incoming requests , something that isn't very clear in its extensive documentation, which can sometimes make troubleshooting difficult. What we need to do is use our favorite text editor to modify the configuration file for this free database management system, which is /etc/my.cnf , and locate the [mysql] section below—or rather, within it.
We add the following lines:
Max_conneccions = 500
max_user_connections = 500
We save the file and restart the service:
Systemctl Restart MySQLD.Service
Now our MySQL can accept 500 incoming connections simultaneously , a more than decent number for most cases, although of course it is totally arbitrary and we can set any other number according to our needs to be able to handle many requests and thus be safe not only from a very large demand but also from any unintentional programming error (which is the other cause of this problem).