一、第一种错误:
I met this problem today, and fix it with bellowed steps.
1, Check the log file /var/log/mysqld.log
1. 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) 2. 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
1. 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) 2. 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
1. # service mysqld restart 2. Restarting mysqld (via systemctl): [ OK ]
二、我遇到的错误:
1. 2018-08-21T13:47:19.515463Z 0 [ERROR] InnoDB: The innodb_system data file 'ibdata1' must be writable 2. 2018-08-21T13:47:19.515504Z 0 [ERROR] InnoDB: The innodb_system data file 'ibdata1' must be writable 3. 2018-08-21T13:47:19.515520Z 0 [ERROR] InnoDB: Plugin initialization aborted with error Generic error 4. 2018-08-21T13:47:20.117768Z 0 [ERROR] Plugin 'InnoDB' init function returned error. 5. 2018-08-21T13:47:20.117827Z 0 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed. 6. 2018-08-21T13:47:20.117840Z 0 [ERROR] Failed to initialize builtin plugins. 7. 2018-08-21T13:47:20.117847Z 0 [ERROR] Aborting
就是没有权限,需要对mysql用户进行授权:
两种方法:
一、安装完之后修改当前目录拥有者为root用户,修改data目录拥有者为mysql
1. chown -R root:root ./ 2. 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
AIEarth是一个由众多领域内专家博主共同打造的学术平台,旨在建设一个拥抱智慧未来的学术殿堂!【平台地址:https://devpress.csdn.net/aiearth】 很高兴认识你!加入我们共同进步!