Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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?

share|improve this question
add comment

3 Answers 3

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.

http://dev.mysql.com/doc/refman/5.1/en/server-options.html#option_mysqld_socket

share|improve this answer
add comment

Have you started your MySQL service after upgrade?

service mysql restart
share|improve this answer
add comment

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

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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