Indonesia Website Awards
Indonesia Website Awards

If you have an application that uses MySQL or MariaDB databases, then over time the users of the application are increasing, maybe you will encounter an error SQLSTATE[HY000] [1040] Too many connections  . The error is because your maximum number of database connections has been exceeded. By default MySQL provides a maximum number of connections of 151 connections. So, we need to increase the maximum number of connections if we encounter this error. Well, here’s how to fix mysql error “Too many connections” :

 

As I mentioned, the fix is to increase the maximum number of connections on your mysql or mariadb. The variable that specifies this value is named max_connections. We can increase this value permanently or not. To increase the value permanently, we can directly edit / add the max_connections variable in the my.cnf file in the  [mysqld] section like this:

[mysqld]
max_connections = 250

*example here I increase the value to 250

 

Next, for a non-permanent method (the value will return every time the mysql or mariadb service is restarted) you just need to enter mysql or maridb then run the following query:

SET GLOBAL max_connections = 250;

 

To check the results of the change in value, you can run this query:

show variables like 'max_connections';

 

Yep, that’s how to fix mysql error “Too many connections” that I can share. By following these steps, the error should no longer appear and the application will run normally. Thank you for reading 😀

 

REFERENCE : https://dev.mysql.com/doc/refman/8.0/en/too-many-connections.html

 

 

Also Read:


0 Comments

Leave a Reply

Avatar placeholder

Your email address will not be published. Required fields are marked *