By jplafata
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!
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 :
- systemctl start mysql
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 and upgrade 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 your wp_config.php and make sure you have the proper details configured there for your DB.
Then make sure your MySQL instance is running:
- systemctl status mysql
- systemctl restart mysql
Hello there,
We have an article on How To Debug the WordPress "Error Establishing Database Connection which you can check here:
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!
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.