Mysql and lamp issue: Warning: mysqli_real_connect(): (HY000/2002)

Hi guys, I hope you can help me, since 3 days ago I’ve been having issues with my droplet with ubuntu 16.04 and lamp. I use my droplet to run a wordpress site and a crm, both uses mysql, but now the server keeps displaying errors like:

Warning: mysqli_real_connect(): (HY000/2002): No such file or directory in /var/www/html/wp-includes/wp-db.php on line 1538

I tried uninstalling completely mysql 5.7 and resinstalling it, restoring a wp db backup, this worked for like an hour, the site displayed fine but then the error displays again.

Submit an answer

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.

Accepted Answer


You should still make sure that none of the active Apache logs are more than 10 MB:

ls -lh /var/log/apache2/

Otherwise it will slow down Apache a lot - and it will consume way too much memory.

And it sounds like you’re being attacked, so I would recommend that you setup Fail2ban or something similar - or one of the many security plugins for WordPress might help too:

Hi @kvnzavalza

How big is your droplet - $5, $10, …?

Can you post the last 40 lines from your MySQL error log by running this command?

tail -40 /var/log/mysql/error.log

And can you also post your database connection host:

grep "DB_HOST" /var/www/html/wp-config.php

What is going on in the PHP code in the aforementioned file on line 1538? It really looks like a file is missing somewhere.

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Featured on Community

Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.

Become a contributor

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow — whether you're running one virtual machine or ten thousand.

Learn more
DigitalOcean Cloud Control Panel