mysql更改数据目录后启动报错问题: File ‘./binlog.index‘ not found (OS errno 13 - Permission denied)

问题描述:

centos7安装好mysql后,在做数据迁移时,将数据目录指向了一个新的地址,然后使用systemctl restart mysqld启动mysql时失败

查看日志/var/log/mysqld.log发现报错信息如下

2023-05-03T08:28:50.048884Z 0 [Warning] [MY-010091] [Server] Can't create test file /mnt/sdb/mysqldata/mysql/mysqld_tmp_file_case_insensitive_test.lower-test
2023-05-03T08:28:50.049000Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.31) starting as process 18157
2023-05-03T08:28:50.052848Z 0 [Warning] [MY-010091] [Server] Can't create test file /mnt/sdb/mysqldata/mysql/mysqld_tmp_file_case_insensitive_test.lower-test
2023-05-03T08:28:50.052860Z 0 [Warning] [MY-010159] [Server] Setting lower_case_table_names=2 because file system for /mnt/sdb/mysqldata/mysql/ is case insensitive
mysqld: File './binlog.index' not found (OS errno 13 - Permission denied)
2023-05-03T08:28:50.054952Z 0 [ERROR] [MY-010119] [Server] Aborting
2023-05-03T08:28:50.055419Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.31)  MySQL Community Server - GPL.

问题解决:

#临时关闭selinux防火墙
1.[root@localhost mysql] setenforce 0
#永久关闭:vim /etc/sysconfig/selinux,将selinux=cnforcing改为selinux=disable
2.[root@localhost mysql] vim /etc/sysconfig/selinux 

在这里插入图片描述

关于SELinux

什么是SELinux

SELinux(Security-Enhanced Linux) 是美国国家安全局(NSA)对于强制访问控制的实现,是 Linux历史上最杰出的新安全子系统。
selinux(security enhanced linux)安全强化的linux,它是一个linux内核模块,也是linux的一个安全子系统。

setenforce 0 的作用

表示 设置SELinux 成为permissive模式 临时关闭selinux防火墙
永久关闭:输入命令vi /etc/selinux/config,将SELINUX=enforcing改为SELINUX=disabled,然后保存退出

SELinux的工作模式

模式 解释
enforcing 强制模式,违反 SELinux 规则的行为将被阻止并记录到日志中
permissive 宽容模式,违反 SELinux 规则的行为只会记录到日志中,作为调试用
disabled 关闭 SELinux

猜你喜欢

转载自blog.csdn.net/qq_29864051/article/details/130473784