MySQL – Where is mysql.sock?

Hi everyone,

A long time I didn’t post about some problem, but today I had a problem with MySQL and I guess that many people had same problem.

I’d like share with yours. When I try to login in the terminal MySQL reply me:

bash-3.1# mysql
ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/var/run/mysql/mysql.sock’ (2)

What’s a hell?

System

Slackware 12.1

Mysql Server version: 5.0.51b

Problem

MySQL sever when it’s (mysqld) starts, it created a sock file.

Ok. but where is the problem?

So, when We tried to start the mysql client(#mysql -u root) it looking for mysql.sock but could not
find the path to the file.

The cause of the error is because the mysql client can’t find the socket file at runtime.

Solution

Necessary create the file mysql.sock. But before please you should verify that mysqld is running:

#ps aux | grep [m]ysqld

Ok. I wrote simple path for mysql.

Download here

Running
#./pathMsql.sh

Check #ls /var/run/mysql
mysql.sock

Sure, it`s created mysql.sock. Now running:

#mysql
mysql>

Conclusion

I hope this help you all. Case you know other suggestion is welcome.

Cya brothers..

Razec


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s