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

I installed LAMP on my Ubuntu machine.

Where Apache2 and PHP5 were installed correctly, as when running apache2 -v and php5 -v I get their installed versions.

But I'm not sure how to check if My My-SQL is installed correctly or not.

Because when I run the mysql -u root -p command, I get the following error.

ERROR 2002 (HY000): it is not possible to connect to the local MySQL server via the socket '/var/run/mysqld/mysqld.sock' (2)

Please, help!

+6
source share
5 answers

you can try starting mysql first

ln -s / var / lib / mysql / mysql.sock / tmp / mysql.sock

mysql start service or service mysql start

+10
source

try changing the root password:

 sudo service mysql stop sudo /usr/bin/mysqld_safe --skip-grant-tables & mysql -h localhost 

(now we use mysql without any user rights)

 > 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 using mysql with a new password, for example:

 mysql -uroot -p Enter password: enter the new_password 

it should work :)

+11
source

To solve this problem, you need to execute the 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 the mysql console

 mysql -u root -p mysql> 
+8
source

You need to start the mysqld service on your computer first. Use the command below to start the mysqld service

mysqld start service

+1
source

Not sure if this would be useful, but I ran into the same issue on my VPS. As it turned out, I ran out of free space by making an hourly backup.

try the following:

 df -h 

If you have 100% disk usage, the server cannot write anything to the disk, no logs, temporary files, nothing.

I deleted some old backups. First find them (run inside the backup folder)

 find . -type f -name "backup-2016-01*" 

This command will find any whit file name starting with backup-2016-01 ...

Then delete these files:

 find . -type f -name "backup-2016-01*" -delete 

Or move them to another place. Then evaluate df -h again to see if you have more space. It helps me.

0
source

All Articles