mysql服务启动失败,查看/var/log/mysql/error.log文件发现如下错误:
[ERROR] InnoDB: The innodb_system data file 'ibdata1' must be writable
[ERROR] InnoDB: The innodb_system data file 'ibdata1' must be writable
[ERROR] InnoDB: Plugin initialization aborted with error Generic error
[ERROR] Plugin 'InnoDB' init function returned error.
[ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
[ERROR] Failed to initialize builtin plugins.
[ERROR] Aborting
试了网上的修改文件目录权限、删除ib_logfile文件都没用。
最终解决办法:
1. 进入/etc/apparmor.d目录
2. 修改usr.sbin.mysqld文件内容,文件中加上如下两行内容(路径根据自己mysql数据库实际目录确定)
/var/lib/mysql/ r,
/var/lib/mysql/** rwk,
3. 重启apparmor和mysql服务
systemctl restart apparmor
systemctl restart mysql.service
问题解决!