I have upgraded MySQL from version 5.0 to version 5.1 and now cannot access mysql from the commandline as mysql -uroot. The error message is as follows: Can't connect to local MySQL server through socket '/var/run/mysql/mysql.sock'

on linux openSuSE 11.1.

Does this relate to my hosts file being incorrect? or is the suse MySQL packages broken?


The problem is that the mysql client can't find the unix socket used for communicating with the mysql server. This is either because mysqld isn't running, mysqld isn't creating the socket or the socket is in the wrong place.

Things to check:

  1. Is mysqld running? "ps aux | grep mysql". Try restarting it
  2. Is mysqld creating the socket? "lsof -p $mysqld_pid | grep sock"
  3. Is it in the right place. Have a look at the "socket" option in the server config. The default is "/tmp/mysql.sock" You might need to set this to match your client or change the client config to match the server location.



Have you started your MySQL service after upgrade?

service mysql restart

The problem is that the mysql client detects its settings from two files /etc/my.cnf or ~/.my.cnf .
The user account in the group 100, did not have a value for the mysql.sock socket file, this value was however set for root. Typically /etc/my.cnf seems to have had read access for users not in the mysql group, however under openSuSE 11.0 and mysql 5.1 this file now has rw access for mysql and read only access to the group and no access to users not in the group. By giving users read only access to the file i managed to fix the problem, however no i the problem is the permissions on the mysql.sock file. Which i still need to create

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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