Linux – Mysql “Can’t connect to local MySQL server through socket ‘/var/run/thesqld/thesqld.sock’ (2)”

linuxMySQLUbuntu

I have got problem with my mysql. It started with that I was importing a dump with the workbench tool. I waited about 30 mins for it to finish but nothing happened so i decided to press stop, to my surprise that did no work either so i close the application and opened it again. Under the tab server status i could see that it was still working on it i decided then to wait a while longer to see what would happen. The sql script seemed to finish but after that mysql was unusable. I can no longer start mysql if i do it with the workbench tool i get the error

Start server

A permission error occurred while attempting to start the
server. Administrator password was possibly wrong.

If i try to access mysql by CL

mysql -u root -p -h localhost -P 3306

I get errors like this.

ERROR 2002 (HY000): Can't connect to local MySQL server through socket
'/var/run/mysqld/mysqld.sock' (2)

How can i fix this so i can use my mysql databases again?

Best Answer

Ok, here is:

  • Delete mysqld.sock
    rm /var/run/mysqld/mysqld.sock
  • Restart the mysqld service
    service mysqld stop
    service mysqld start
  • Try to access to mysql client
    mysql -u root -h localhost -p

Note:

If you really need connect to that port, then do it, avoid that otherwise.