一. 场景描述
1. mysql版本: MySQL-server-5.6.35-1.el6.x86_64.rpm
2. mysql原始目录:/var/lib/mysql
3. mysql修改后的目录: /home/mysqldata
二. 故障描述
1. 通过mysql -uroot -p 登录,输入密码回车后如下提示:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) 的解决办法
解决办法:创建软链接
ln -s /home/mysqldata/mysql.sock /var/lib/mysql/mysql.sock
2. 通过mysql -uroot -p 登录,输入密码回车后如下提示:
[root@TEST40 etc]# mysql -uroot -p
Enter password:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
解决方法:
#mv /var/lib/mysql/mysql.sock /tmp
结果如下:
[root@TEST40 mysql]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.6.35-log MySQL Community Server (GPL)
Copyright (c) 2000, 2016, 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>