Symptoms
In some instances, all websites on the server that utilizes a MySQL database may throw the following error at once:
Error establishing a database connection
When reviewing the MySQL error log, you may see many lines that include the following error:
2020-08-13T04:08:52.857868Z 1554 [Note] Aborted connection 1554 to db: 'user_database' user: 'user_username' host: 'localhost' (Got an error writing communication packets)
Description
A common cause for this issue is that a particular database is overloading the local MySQL server with many requests that are not closing out correctly. This can be confirmed with the following command:
mysqladmin processlist | awk '{print $8}' | sort | uniq -c | sort -n
This is particularly prevalent on WordPress sites with plugin or theme conflicts.
You may see one particular database that is listed many times, as in this example:
[09:19:06 centos root@93587720 ~]cPs# mysqladmin processlist | awk '{print $8}' | sort | uniq -c | sort -n
1 |
1 db
151 user_database
Workaround
In these instances, it is recommended that you first disable all of the plugins for the particular WordPress site by moving the plugins folder out of the way. You can do so after navigating to the wp-content directory for the site and executing the following command:
mv -v plugins{,.back}
Once done, you can restart MySQL to reset the connections with the following command:
/scripts/restartsrv_mysql
After that completes, you should be able to refresh your page, and the site should load without a Database Connection error.
At that point, the developer for the site that was overloading the server will need to go into the WordPress backend and diagnose which plugins may have been causing the issue.
Comments
0 comments
Article is closed for comments.