Bug #29748 Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock'
Submitted: 12 Jul 2007 3:51 Modified: 12 Jul 2007 4:51
Reporter: Todd Suess Email Updates:
Status: Not a Bug Impact on me:
Category:MySQL Server: General Severity:S1 (Critical)
Version:4.1 OS:Linux
Assigned to: CPU Architecture:Any
Tags: MySQL, mysql error, mysqlsock

[12 Jul 2007 3:51] Todd Suess

My name is Todd and I have a very serious MySQL error. I've had my server for almost a year now with MySQL 4.1 installed and running perfectly. Until just an hour ago, I returned home to find out that MySQL isn't working. It's very strange.

The processes are running as:
/usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --user=mysql --pid-file=/var/run/mysqld/mysqld.pid --skip-locking --port=3306 --socket=/var/run/mysqld/mysqld.sock

/bin/sh /usr/bin/mysqld_safe

logger -p daemon.err -t mysqld_safe -i -t mysqld

I used MySQL admin to restart it and it told me it restarted perfectly with no errors. But now when I try to start a slave or get it to work through PHP, I receive this error: "connect to server at 'localhost' failed
error: 'Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)'".

I need help immediately. Much appreciated!

Todd Suess

How to repeat:
Does this mean how to repeat the process? Okay, well I noticed MySQL wasn't starting because of a log file error. I forget the message but it told me something about a log file not working. I cleared the logs and started again and then it told me:

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!

So I removed the "mysqld" folder from "/var/run".

And now I'm stuck. :-(

Suggested fix:
I'm not sure but I think it must be something related to the mysqld.sock file. I also think that permissions are a big thing and I changed the permissions to the "mysql" user and group permissions. I'm not sure if that's what it is, but I think that's
[12 Jul 2007 4:28] Valeriy Kravchuk
Thank you for a problem report. Please, send your error log and the results of:

ls -l /var/run
netstat -a | grep mysqld

I do not think that this is a result of some bug in the code, by the way.
[12 Jul 2007 4:35] Todd Suess

I isolated the problem. It's a permissions problem. I was messing with "my.cnf" and when I change the "user" variable to "root" it works fine, but when it's at a default of "mysql", it gives me trouble. I would like to correct the permissions on this if possible, but it seems like what I've tried on fixing the folder permissions hasn't worked.

Here are the permissions of MySQL's essential files:
user:mysql | group:mysql
user:mysql | group:mysql

Are there any other files that would be essential to this?

Before this, the permissions used to be "user:root" and "group:mysql" but that doesn't seem to work.
[12 Jul 2007 4:47] Valeriy Kravchuk
We're sorry, but the bug system is not the appropriate forum for asking help on using MySQL products. Your problem is not the result of a bug.

Support on using our products is available both free in our forums at http://forums.mysql.com/ and for a reasonable fee direct from our skilled support engineers at http://www.mysql.com/support/

Thank you for your interest in MySQL.
[12 Jul 2007 4:51] Todd Suess
Whoops! Sorry about that. Thanks for your help! Much appreciated!