Linux上mysql登陆错误解决办法ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/

时间:2022-12-12 00:30:00

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

Linux上mysql登陆错误解决办法ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/


解决方法: 1:首先确认你在root权限下

[root@localhost tmp]# mysql -u root -p
Enter password: 
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock'

Linux上mysql登陆错误解决办法ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/

2:确保你的mysql关闭

service mysqld stop

Linux上mysql登陆错误解决办法ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/

3:将你本身安装目录下的mysql设快捷键到规定的目录下

ln -s /tmp/mysql.sock /var/lib/mysql/mysql.sock

Linux上mysql登陆错误解决办法ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/

4:重新打开mysql

[root@localhost tmp]# service mysqld start

5:成功mysql -u root -p

Linux上mysql登陆错误解决办法ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/