Question

Error establishing database connection (WordPress)

Posted May 19, 2016 2.9k views
MySQL WordPress LAMP Stack Ubuntu 16.04

So I am getting this error while accessing my WordPress site. I mitigated XMLRPC attack and added swap file but to no avail.

While trying to connect to DB using ‘mysqladmin -u root -p status’ command, I am getting below error.

mysqladmin: connect to server at 'localhost’ failed
error: 'Can’t connect to local MySQL server through socket ’/var/run/mysqld/mysqld.sock’ (2)’
Check that mysqld is running and that the socket: ’/var/run/mysqld/mysqld.sock’ exists!

Can anyone please help me troubleshoot this? I am on 512 MB droplet.

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.

1 answer

open this following file

sudo nano /etc/mysql/my.cnf

and check in section [mysqld] for Bind address. make sure its properly configured.

Submit an Answer