Krax
Krax

Reputation: 11

Can't connect to mysql

I am have trouble connecting to a mysql server. The error I'm getting is:

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysql/mysql.sock' (2)

Upvotes: 0

Views: 1028

Answers (4)

spooks
spooks

Reputation: 49

First please check if the file /var/run/mysql/mysql.sock exists.If not then create one in the same path with no content in it.And then do a mysql stop start using /etc/init.d/mysql stop(for stop) and /etc/init.d/mysql start .If even then mysql does not work , try user265130 solution.

Upvotes: 1

niting112
niting112

Reputation: 2640

As a root user type in mysqld_safe and then from other terminal type your normal starting command like mysql -u USERNAME -p and you wont get the above error..

Upvotes: 0

user623666
user623666

Reputation: 1

Try to connect with '127.0.0.1' instead of 'localhost'. You might have to also so supply the port (-P 3306)

Upvotes: 0

ilovekhym
ilovekhym

Reputation: 105

try to locate the valid socket for your connection.

if your using zend, you can configure it like this:

db.config.unix_socket = "/var/run/mysqld/mysqld2.sock"

Upvotes: 0

Related Questions