问题背景
Centos7 安装Mysql 8后启动时遇到的问题,看了好几个博客方案无效,搞了半小时才找到正解,在此次进行记录。
在此假设你已经修改了对应目录的权限,比如配置的mysql data目录初始化后已经执行了chown -R mysql:mysql /XXX/data
问题呈现
启动失败后systemctl status mysqld
查看状态如下
查看启动日志信息 /var/log/mysqld.log 如下
2023-10-20T06:23:20.320468Z 0 [Warning] [MY-010091] [Server] Can't create test file /data/mysql/data/mysqld_tmp_file_case_insensitive_test.lower-test
2023-10-20T06:23:20.320513Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.34) starting as process 13397
2023-10-20T06:23:20.323497Z 0 [Warning] [MY-010091] [Server] Can't create test file /data/mysql/data/mysqld_tmp_file_case_insensitive_test.lower-test
2023-10-20T06:23:20.323513Z 0 [Warning] [MY-010091] [Server] Can't create test file /data/mysql/data/mysqld_tmp_file_case_insensitive_test.lower-test
mysqld: File './binlog.index' not found (OS errno 13 - Permission denied)
2023-10-20T06:23:20.324136Z 0 [ERROR] [MY-010119] [Server] Aborting
2023-10-20T06:23:20.324361Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.34) MySQL Community Server - GPL.
解决方案
参考这篇博客:https://www.cnblogs.com/shanxia0812/p/14536755.html,
执行
selinux 0
临时关闭linux安全子系统,修改/etc/selinux/config文件中设置SELINUX=disabled,然后重启或等待下次重启
问题解决