问题描述:在终端中输入mysql出现: ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/run/mysqld/mysqld.sock' (2 "No such file or directory")
根据错误提示知道是没有启动mysql服务器,于是立马在终端中输入mysqld命令启动mysql服务器,然而又在次报错:
2017-05-31 10:54:51 139998512155840 [Note] mysqld (mysqld 10.1.23-MariaDB) starting as process 3154 ...
2017-05-31 10:54:51 139998512155840 [Warning] Can't create test file /var/lib/mysql/zihao-pc.lower-test
mysqld: Can't change dir to '/var/lib/mysql/' (Errcode: 13 "Permission denied")
2017-05-31 10:54:51 139998512155840 [ERROR] Aborting
看这错误提示猜测可能是/var/lib/mysql 文件权限不正确,于是 ls -l /var/lib 查看权限为:drwx------果断改为:drwxrwxrwx ,然后再次执行mysqld命令又出新错误:
2017-05-31 10:58:36 140654622538944 [ERROR] Can't start server : Bind on unix socket: Permission denied
2017-05-31 10:58:36 140654622538944 [ERROR] Do you already have another mysqld server running on socket: /run/mysqld/mysqld.sock ?
2017-05-31 10:58:36 140654622538944 [ERROR] Aborting
错误原因和上个步骤类似,这次将/run/mysqld 目录权限更改为:drwxrwxrwx,然后再次执行mysqld完美运行!