Ran apt update and apt upgrade and I cannot access WordPress admin area

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!

Submit an answer
Answer a question...

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!

Sign In or Sign Up to Answer

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.

Site Moderator
Site Moderator badge
April 1, 2022

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!

Site Moderator
Site Moderator badge
April 1, 2022

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 :

  1. 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:

  1. systemctl status mysql
  2. systemctl restart mysql