今天把虚拟机中的centos 从机械硬盘转移到固态硬盘,然后启动mysql时报错:
[root@localhost ~]# mysql
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
解决办法:
[root@localhost opt]# ls /var/lib/mysql/mysql.sock
ls: 无法访问/var/lib/mysql/mysql.sock: 没有那个文件或目录
[root@localhost opt]# ln -s /storage/db/mysql/mysql.sock /var/lib/mysql/mysql.sock
[root@localhost opt]# ls /var/lib/mysql/mysql.sock
/var/lib/mysql/mysql.sock
[root@localhost ~]# systemctl restart mysqld
[root@localhost ~]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.16 MySQL Community Server (GPL)
Copyright (c) 2000, 2013, 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.
参考文档:https://www.cnblogs.com/Lam7/p/6090975.html