Linux/Python学习论坛-京峰教育

 找回密码
 立即注册

一键登录:

搜索
热搜: 活动 交友 discuz
查看: 425|回复: 0

mysql报错ERROR 2002 (HY000): Can't connect to local MySQL server through ...

[复制链接]

217

主题

331

帖子

4642

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
4642
QQ
发表于 2016-7-29 15:59:06 | 显示全部楼层 |阅读模式
大家在学习mysql的时候,遇到最多的问题如下:
ERROR 2002 (HY000): Can't connect to local MySQL server through
socket '/tmp/mysql.sock' (2)
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
解决思路如下:
1、检查mysql服务器是否已经启动
ps -ef |grep mysql
2、检查/tmp/mysql.sock是否存在,如果不存在,
ps -ef |grep mysql 可以看到mysql.sock文件的路径;
一般在/var/lib/mysql/mysql.sock下,可以做软连接解决:
ln -s
/var/lib/mysql/mysql.sock  /tmp/mysql.sock
3、其他问题需要查看mysql错误日志
tail -fn 100 /var/log/mysqld.log



京峰Linux教育创始人之一,只为有梦想的人!任何事情只要去行动,就会收获结果!
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|小黑屋|京峰教育,只为有梦想的人 ( 京ICP备15013173号 )

GMT+8, 2017-11-18 12:37 , Processed in 0.031025 second(s), 16 queries , Apc On.

快速回复 返回顶部 返回列表