We help IT Professionals succeed at work.

can't open mysql

I've had this server running for years but suddenly i get the error

'/var/run/mysqld/mysqld.sock' (2)

when I try to run my website which accesses the mysql server.

If I log into the server and try to log in to msqyl, I get a similar error.

web:~# mysql -u root
ERROR 2002: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)

I tried to locate a socket that was open, but the mysql did not appear to be open:

THEN i tried to see if mysql was running and to start it:
web:~# ps aux | grep mysqlps aux | grep mysql
grep: aux: No such file or directory
web:~# /etc/init.d/mysql start
Starting MySQL database server: mysqld...failed.
        Please take a look at the syslog.
/usr/bin/mysqladmin: connect to server at 'localhost' failed
error: 'Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)'
Check that mysqld is running and that the socket: '/var/run/mysqld/mysqld.sock' exists!

I have no idea where to go now ...

thanks in advance.
Watch Question

rm /var/run/mysqld/mysqld.sock
/etc/init.d/mysql start

Open in new window

Explanation: when Mysql crashes, it does not delete the mysqld.sock file. Then, when you try to start it, it sees that the file exists and assumes there is another instance opened.
Just remove myqld.sock and you'll be able to start the daemon.




I tried that, but it resulted in the following error message:

web:/etc/mysql# rm /var/run/mysqld/mysqld.sock
rm: cannot remove `/var/run/mysqld/mysqld.sock': No such file or directory

What's happens if you run
Maybe your MySQL-Server creates the socket file somewhere different? (like /tmp)


No, that's the right place for it. I confirmed that in my.cnf

Have you tried mysqld_safe? If it's not in /etc/init.d then find it's location with
which mysqld_safe
I found the problem. There was an incorrect bind_address in my.conf.

Thanks to all