I really hope someone can help me out with an issue I’m facing. I have a droplet with WordPress on a LAMP stack. This evening I ssh’d into my droplet and ran apt-get update
and upgrade
where some mysql and php packages were fetched and installed. I then went to the browser where I had I was already logged into the WordPress dashboard, I started using it, but was soon met with an error that read: Error establishing a database connection
. I went back into ssh and enabled debugging and reloaded the page in the browser and have a little more info. The full error (warning) is:
Warning: mysqli_real_connect(): (HY000/2002): No such file or directory in /var/www/html/wp-includes/wp-db.php on line 1753 No such file or directory
I’m not exactly sure where to start in fixing this issue. Any help would be appreciated!
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
Hello there,
We have an article on How To Debug the WordPress "Error Establishing Database Connection which you can check here:
https://www.digitalocean.com/community/tutorials/how-to-debug-the-wordpress-error-establishing-database-connection
As for the apt-update and apt-upgrade process of the droplet, I’ll recommend first creating a backup of the site (or taking a snapshot of the droplet) before pushing the update/upgrade. In this way, you’ll have a recovery point in case something goes wrong.
Hope that this helps!
Hi @jplafata,
The first error
Error establishing a database connection
was related to your MySQL instance, most probably it was down and it had to be started again :The next error
mysqli_real_connect(): (HY000/2002): No such file or directory in /var/www/html/wp-includes/wp-db.php on line 1753 No such file or directory
Now that is related to your WordPress installation. It’s really weird that after an
apt-get update
andupgrade
on your Droplet this has appeared as the two (upgrades and your WordPress) are totally different processes. Having said that, I suspect this is related to your MySQL. Check yourwp_config.php
and make sure you have the proper details configured there for your DB.Then make sure your MySQL instance is running: