I tried restarting the Mysql server but its not working for me. I am sure the server is running and the permissions on the folder /var/lib/mysql/ are correct (777).

When i tried to open the file mysql.sock, its giving me an error saying the file may be corrupt.

Please help me to log on to the mysql server.

  • Question : Is mysqld still running but you cannot connect? Commented Jan 20, 2012 at 17:57
  • Please run service mysql status and post the output of that command Commented Jan 20, 2012 at 18:05

4 Answers 4


First: Make sure that the owner of /var/lib/mysql and its files and subdirectories is mysql user of mysql group

to do that run the following command:

chown mysql:mysql -R /var/lib/mysql/*

Second: change write permissions to rwxr-xr-x (755) for mysql directory, and all its files and subdirectories, by running the following command:

chmod 755 -R /var/lib/mysql/*

now start mysql service

service mysql start
  • Did everything you suggested, but could not find the mysql.sock file in the folder you specified
    – vinny
    Commented Jan 20, 2012 at 5:53
  • Please tell the location of socket file by seeing from my.cnf. Commented Jan 20, 2012 at 6:14

i had same problem and solved with:

mysql_install_db --user=mysql

reference: https://mariadb.com/kb/en/installing-system-tables-mysql_install_db/


For me, stopping docker in the background was the solution. Nothing else worked, and nothing pointer to docker except when running

lsof -i TCP:3306

and then trying to

kill <process_id> 

the error from docker popped up so I knew Docker was having some background mysql listeners.


Just do it, it worked to me...

mysql.server start

[mysql -u "username" -p "password"]

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.