记一次 mysql 不能启动问题的流水账
linux 下启动 mysql 报错(#为提示字符)
# systemctl restart mysqld
报错 如下
[ERROR] InnoDB: Operating system error number 13 in a file operation. [ERROR] InnoDB: The error means mysqld does not have the access rights to the directory. [ERROR] InnoDB: os_file_get_status() failed on './ibdata1'. Can't determine file permissions [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
此时考虑是由 selinux 引起的问题
临时方案 : 关闭 selinux
1 # getenforce # 查看selinux 状态 “Enforcing” 为selinux 强制开启 。“Permissive” 为 selinux 只 监控不阻止命令 执行 2 # setenforce 0 # 修改selinux为 Permissive
selinux 修改后,重新尝试 启动mysql ,成功。
再次修改selinux为 Enforcing 后 ,重新出现“Operating system error number 13 in a file operation.”
问题:如何保持selinux 的强安全模式 且 mysql 服务正常 ?
答: 修改 selinux的mysql安全配置项
1 # getsebool -a |grep mysql 2 mysql_connect_any --> off 3 selinuxuser_mysql_connect_enabled --> off
问:如何打开 配置项
1 # setsebool -P selinuxuser_mysql_connect_enabled on 2 # setsebool -P mysql_connect_any on
修改selinux为 Enforcing 后 ,mysql 服务正常 。
参考文献:
https://www.percona.com/doc/percona-server/8.0/security/selinux.html