mysql连接错误ERROR 2002 (HY000)解决方法
所属分类 mysql
浏览量 1330
mysql
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
mysql -h localhost
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
mysql -h 127.0.0.1
ERROR 1045 (28000): Access denied for user 'xxx'@'localhost' (using password: NO)
使用 mysql -h 127.0.0.1 可以连接
本地连接使用 socket文件方式, socket文件在 /etc/mysql.cnf 里配置
找不到 socket 文件则报错
检查 MySQL 服务状态
service mysqld status
SUCCESS! MySQL running (49903)
确定 socket 文件 路径
lsof -c mysqld |grep sock
/data01/mysql/mysql5.7/log/mysql.sock
或者
lsof -c mysqld |grep sock
find / -name '*.sock'
解决方案
/etc/my.cnf
把client和mysqld的socket 文件配置成一样 即可
查看文件信息
file /tmp/mysql.sock
stat /tmp/mysql.sock
mysql -u root -p
show databases;
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
set password="YOUR_PASSWORD";
上一篇
下一篇
CAPEX和OPEX的具体含义
架构的三个维度和六个层面
hadoop2.0生态技术简介
maven处理本地jar包依赖
spring bean 生命周期实例
spring4种注入方式