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

解决这个问题
ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/var/lib/mysql/mysql.sock’ (2)

1、启动mysql
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (_第1张图片
初始密码在less mysqld.log文件里找,关键词是password

赋权给远程访问
登陆数据库
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (_第2张图片

update user set host ='%' where user ='root';
update user set host ='%' where user ='budget';

修改成如下才可以。
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (_第3张图片
最后一步很重要

FLUSH PRIVILEGES;

。然后就可以解决了。

更多技术文章请关注公众号:架构师Plus,
扫码添加
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (_第4张图片

你可能感兴趣的:(数据库)