Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2).

This Comment will be submitted for moderation and will not be accessible to other users until it has been approved.


-22 points

I am a LAMP newbie.

==== Environment ======
OS = Ubuntu 6.06
MySQL = v5.0.22
PHP = v5.1.6
Apache = v2.2.3
=======================

I am getting very strange error with Mysql:

Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)

I have checked the error message
Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)

Can anyone provide insight as to what the problem is and how to resolve it?

Please keep in mind that I am a newbie; something that may be obvious to you may be totally unknown to me.
Thank you in advance for any assistance you can provide.



6 points

One thing that can cause that problem is if you haven't started the mysqld service.

Anonymous's picture
Created by Anonymous
0 points

Member

Registered: Dec 2002
Location: us
Posts: 108
Blog Entries: 262
Thanked: 0

Original Poster

thanks for your reply.I can confirm mysqld is running

ps -ef | grep mysqld
root 951 1 0 09:00 ? 00:00:00 /bin/sh /usr/bin/mysqld_safe
root 987 951 0 09:00 ? 00:00:00 /bin/sh /usr/bin/mysqld_safe
mysql 988 987 0 09:00 ? 00:00:00 /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
root 989 987 0 09:00 ? 00:00:00 logger -p daemon.err -t mysqld_safe -i -t mysqld
mysql 990 988 0 09:00 ? 00:00:00 /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
mysql 991 990 0 09:00 ? 00:00:00 /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
mysql 992 990 0 09:00 ? 00:00:00 /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
mysql 993 990 0 09:00 ? 00:00:00 /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
mysql 994 990 0 09:00 ? 00:00:00 /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
mysql 995 990 0 09:00 ? 00:00:00 /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
mysql 996 990 0 09:00 ? 00:00:00 /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
mysql 997 990 0 09:00 ? 00:00:00 /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
mysql 998 990 0 09:00 ? 00:00:00 /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

Anonymous's picture
Created by Anonymous
3 points

Can you check if the mysql user has read/write permissions on the /var/run/mysqld folder?

Best regards,
Uros

Anonymous's picture
Created by Anonymous
-4 points

A quick check list:

1. check your my.cnf config files if they are okey. All the relevant settings must be righ i.e path to socket files, etc...

2. check for correct permission on the files and dirs in question. Also check for the correct permissions of the folder where the mysql tables reside. Also check who owns the files

3. Don't manually run mysql, run it with the /etc/init.d script

Sorry I'm not smart enough to solve your problems via the forum. I too had some problems like you guys are experiencing and it all ways was a file permission problem. If my memory serves me correctly that is, it's been a long time ago..

...and please post the log files relevant to the mysqld error and also my.conf settings.

And perhaps, this is a wild shot, you guys could try to run "touch /var/run/mysqld/mysqld.sock" and chown the file to mysql user and then try to run the mysql daemon.

Best regards,
Uros

Anonymous's picture
Created by Anonymous

Post Comment

  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>, <c>, <cpp>, <drupal5>, <drupal6>, <java>, <javascript>, <php>, <python>, <ruby>. Beside the tag style "<foo>" it is also possible to use "[foo]". PHP source code can also be enclosed in <?php ... ?> or <% ... %>.