Mysql doesn't start mysqld.sock is missing
To find all socket files on your system run:
sudo find / -type s
My Mysql server system had the socket open at /var/lib/mysql/mysql.sock
Once you find where the socket is being opened, add or edit the line to your /etc/my.cnf
file with the path to the socket file:
socket=/var/lib/mysql/mysql.sock
Sometimes the system startup script that launched the command line executable specifies a flag --socket=path
. This flag could override the my.cnf
location, and that would result in a socket not being found where the my.cnf file indicates it should be.
Then when you try to run the mysql command line client, it will read my.cnf to find the socket, but it will not find it since it deviates from where the server created one. So, Unless you care where the socket resides, just changing the my.cnf to match should work.
If you're super user in the Linux system, based on the above just do this:
kill -9 <pid_of_mysql>
or sometimes you can do this:
pkill -9 mysqld
After you do this you might want to look for a pid file in /var/run/mysqld/
and delete it
Make sure the permissions on your socket is such that whatever user mysqld is running as can read/write to it. An easy test is to open it up to full read/write and see if it still works:
chmod 777 '/var/run/mysqld/mysqld.sock'
If that fixes the issue, you can tailor the permissions and ownership of the socket as needed based on your security settings.
Also, the directory the socket resides in has to be reachable by the user running the mysqld process.
Reference : https://stackoverflow.com/questions/11990708/error-cant-connect-to-local-mysql-server-through-socket-var-run-mysqld-mysq
I tried to startup mysql in "Safe Mode" to create the sock file and pid file, but it fails for some error "bind",
- I changed the IP address in "bind ip" parameter in my.cnf to localhost
- started mysql in safe mode.
- restarted mysql in normal mode, and everything went fine.