Report this

What is the reason for this report?

MySQL -Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)

Posted on September 30, 2014

I currenty have a LAMP, running on Ubuntu 14.04, yesterday everything was fine, but today my MYSQL is not working.

When i try to connect via

mysql -u root -p

I get the error: ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/var/run/mysqld/mysqld.sock’ (2)

the Mysql.err file is completely empty, and have absolute no ideia about what to do.



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!

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.

This comment has been deleted

My problem was running out of memory. Digital ocean has great instruction for adding swap memory for Ubuntu: https://www.digitalocean.com/community/tutorials/how-to-add-swap-on-ubuntu-14-04

This solved the issue and enabled me to restart the Mysql that otherwise would not start.

If you are creating a droplet from snapshot, then make sure to update the bind-address field with the new ip address.

$sudo nano /etc/mysql/my.cnf

Update the bind-address field with new ip address then run

$sudo service mysql start

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.