centos7 下启动MySQL出现以下错误提示:

Job for mysqld.service failed. See 'systemctl status mysqld.service' and 'journalctl -xn' for details.

找到错误日志的路径

[root@bogon usr]# find / -name mysqld.log
/var/log/mysqld.log

查看错误日志发现以下错误:

[ERROR] /usr/sbin/mysqld: Can't create/write to file '/var/run/mysqld/mysqld.pid' (Errcode: 2 - No such file or directory)
[ERROR] Can't start server: can't create PID file: No such file or directory

原因是没有找到mysqld.pid这个文件(实际上是没有/var/run/mysqld/路径,mysqld.pid文件在启动mysql服务时自动生成)

解决办法:

1.创建文件夹
mkdir /var/run/mysqld
2.授权
chown mysql:mysql /var/run/mysqld/

启动MySQL服务

[root@bogon ~]# service mysqld start
或
[root@bogon ~]# /etc/init.d/mysql start
Logo

更多推荐