Error establishing database connection (WordPress)

May 19, 2016 2.7k views
WordPress MySQL 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.

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.

Have another answer? Share your knowledge.