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

try to force redefining the root password:

sudo  service mysql stop

sudo /usr/bin/mysqld_safe --skip-grant-tables &

mysql -h localhost

(now we are using mysql without carring to user privileges)

> USE mysql

> UPDATE mysql.user
SET authentication_string=PASSWORD('new_password')
WHERE user='root' AND host='localhost';

> quit

sudo mysqladmin shutdown

sudo service mysql start

that's all ... now try to use mysql with the new password, like that:

mysql -uroot -p
Enter password: enter the new_password

it should work :)


you could try starting your mysql first

> ln -s /var/lib/mysql/mysql.sock /tmp/mysql.sock
> 
> service mysql start or service mysql start

For resolving this issue, you need to run following commands sequentially

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

After that you can run the following command to go to mysql console

mysql -u root -p
mysql>