Many website owners face the error ” 1203 cannot log in to the MySQL server” after they have recently migrated to a new server or when the server traffic grows.
Here at Bobcares, we have webmasters, web hosts, and other online service providers fix database errors such as this as part of our Server Management Services.
Today we’ll go through the cause of this error and how to fix it.
Common reason for error 1203 Cannot log in to the MySQL server
MySQL error 1203 is commonly related to exceeding the max_user_connections limit on the server. When this limit is exceeded, users face issues connecting through phpMyadmin and through database connections scripts.
Let us look at the possible solutions to fix the issue.
Solution 1: Fix the code
A badly written code is the most common reason for the max_user_connections of the server to exceed. At times, developers forget to close database connections that they open in code.
These connections can be triggered also by a plugin that you installed recently.
Proper identification of the connection opening codes and applying a fix to them can indeed solve the 1203 MySQL error.
Solution 2: Increase max_user_connection
The maximum user connections value of the server at times can be limited to a low value. Consequently, it triggers the “Cannot log in to the MySQL server’ error fast.
It is always a good idea to cross-check the max_user_connections limit, before applying any other fix to this issue. While in MySQL prompt, use the command below to get an idea of the limit:
SHOW VARIABLES LIKE 'max_user_connections'; +----------------------+------------+ | Variable_name | Value | +----------------------+------------+ | max_user_connections | 2147483647 | +----------------------+------------+
The value above is comparatively a higher one. You may need to cross-check with your WebHost before increasing this value as increasing them to a limit beyond what actually the hardware can support will affect the performance of the website adversely.
There are two methods to change the maximum user connections value. Let us look at them one by one.
Method 1: Editing the MySQL Configuration file:
The maximum user connection limit can be increased directly by adding a line as in the /etc/my.cnf file
max_user_connections = <set number that you want>
Method 2: Editing the value command line:
To edit the maximum user connection value of MySQL globally, we can use the command below:
SET GLOBAL max_user_connections = <desired value>;
[Need help to fix MySQL error 1203? We are available 24×7]
In short, exceeding the maximum user connection limit of the server triggers 1203 cannot log in to the MySQL server error. Today we discussed the two methods that our Support Engineers use to fix the issue.