简体   繁体   中英

Mysql Can't connect to local server through socket

This is the error i receive:

I can not connect as any user and it continually says

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

and

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

Output of lsof -i -P | grep :3306

xxx$ lsof -i -P | grep :3306
xxx$ mysqld 20080 mysql 11u IPv4 56434 0t0 TCP localhost.localdomain:3306 (LISTEN)

Narrowed it down a little bit. Whenever I select one of my databases and type

show tables;

I receive

ERROR 2002 (HY000): Can't connect to local MySQL server through socket                     '/run/mysqld/mysqld.sock' (111)
ERROR:
Can't connect to the server

However I can select the other databases just fine. I can't remove the database.

Update

Had to manually remove the problem database and can now connect successfully to mysql.

Are you connecting to MySQL from the same box? ie, localhost?

If you are on a linux box, make sure you can telnet localhost on port 3306

telnet localhost 3306

If your telnet connects then it must be a permissions issue:

Check the file /etc/mysql/my.cnf and make change the bind-adress so it looks like:

bind-addess = 0.0.0.0

If none of the above works, then please post your mysql log

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM