can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' [duplicate]

After checking that /etc/mysql/my.cnf was correct (port=3306, bind-address=127.0.0.1), I was still having trouble. I then got /var/run/mysqld/mysqld.sock automatically by installing mysql-server:

$ sudo apt-get install mysql-server-5.5

I then tried starting the mysql server as thefourtheye said, but still got the same error you're getting when trying to start mysql via $ mysql -u root.

Finally, I found a similar discussion on ubuntu forums that finally fixed it for me.

Here's the only part of the link that I found I needed to do:

$ sudo service mysql stop
$ sudo /etc/init.d/apparmor reload
$ sudo service mysql start

Then I was able to start mysql with $ mysql -u root -p, using the password I set when I installed mysql-server-5.5


sudo service mysql start

Execute this command to start the MySQL server.