linux 安装mysql ERROR:Job for mysqld.service failed See “systemctl status mysqld.service”

版权声明:本文为博主原创文章,能帮到你很开心(^_^)~,欢迎转载,转载请注明出处~ https://blog.csdn.net/qq_36396104/article/details/81915307

一、第一种错误:

I met this problem today, and fix it with bellowed steps.

1, Check the log file /var/log/mysqld.log

 2017-03-14T07:06:53.374603Z 0 [ERROR] /usr/sbin/mysqld: Can't create/write to file '/var/run/mysqld/mysqld.pid' (Errcode: 2 - No such file or directory)
 2017-03-14T07:06:53.374614Z 0 [ERROR] Can't start server: can't create PID file: No such file or directory

The log says that there isn't a file or directory /var/run/mysqld/mysqld.pid

2, Create the directory /var/run/mysqld

mkdir -p /var/run/mysqld/

3, Start the mysqld again service mysqld start, but still fail, check the log again/var/log/mysqld.lo

2017-03-14T07:14:22.967667Z 0 [ERROR] /usr/sbin/mysqld: Can't create/write to file '/var/run/mysqld/mysqld.pid' (Errcode: 13 - Permission denied)
2017-03-14T07:14:22.967678Z 0 [ERROR] Can't start server: can't create PID file: Permission denied

It saids permission denied.

4, Grant the permission to mysql chown mysql.mysql /var/run/mysqld/

5, Restart the mysqld

# service mysqld restart
Restarting mysqld (via systemctl):                         [  OK  ]

 二、我遇到的错误:

2018-08-21T13:47:19.515463Z 0 [ERROR] InnoDB: The innodb_system data file 'ibdata1' must be writable
2018-08-21T13:47:19.515504Z 0 [ERROR] InnoDB: The innodb_system data file 'ibdata1' must be writable
2018-08-21T13:47:19.515520Z 0 [ERROR] InnoDB: Plugin initialization aborted with error Generic error
2018-08-21T13:47:20.117768Z 0 [ERROR] Plugin 'InnoDB' init function returned error.
2018-08-21T13:47:20.117827Z 0 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
2018-08-21T13:47:20.117840Z 0 [ERROR] Failed to initialize builtin plugins.
2018-08-21T13:47:20.117847Z 0 [ERROR] Aborting

 就是没有权限,需要对mysql用户进行授权:

两种方法:

一、安装完之后修改当前目录拥有者为root用户,修改data目录拥有者为mysql

chown -R root:root ./
chown -R mysql:mysql data

 二、

chown -R mysql /var/run/mysqld/

虽然这样可以解决上述错误,但还是出现了很多其他问题,,所以我就直接将原来的mysql给卸载了:

安装前,我们可以检测系统是否自带安装 MySQL:

rpm -qa | grep mysql

如果你系统有安装,那可以选择进行卸载:

rpm -e mysql  // 普通删除模式
rpm -e --nodeps mysql  // 强力删除模式,如果使用上面命令删除时,提示有依赖的其它文件,则用该命令可以对其进行强力删除

然后按照另外一个教程安装配置成功:

 Linux下安装MySQL:https://www.jianshu.com/p/f4a98a905011

猜你喜欢

转载自blog.csdn.net/qq_36396104/article/details/81915307