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

部署mysql版本信息
version: 5.6.21
具体现象:
mysql服务能够正常启动如下:
[root@localhost ~]# service mysqld restart
Shutting down MySQL.. SUCCESS!
Starting MySQL.. SUCCESS!
登陆mysql库出现如下错误:
[root@localhost ~]# mysql
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
解决方法:
经过对如上错误分析,/var/lib/mysql/目录下缺少mysql.sock(mysql的套字节)
[root@localhost ~]# find / -name mysql.sock
/tmp/mysql.sock
只要系统中存在mysql.sock这个文件,接下来解决问题就会很好办如下操作:
[root@localhost ~]# ln -s /tmp/mysql.sock /var/lib/mysql/mysql.sock
重启服务
[root@localhost ~]# service mysqld restart
Shutting down MySQL.. SUCCESS!
Starting MySQL.. SUCCESS!
重新登陆
[root@localhost ~]# mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.6.21 MySQL Community Server (GPL) Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql>

  

上一篇:springMVC(7)---表单标签


下一篇:web开发注意的一些事