#yum安装mysql8.0.32修改二进制日志位置报错mysqld: File '/data/mysql/logbin/mysql-bin.index' not found (OS errno 13 - Permission denied)

发布时间 2023-05-22 17:31:20作者: YYQ-
#yum安装mysql8.0.32修改二进制日志位置报错mysqld: File '/data/mysql/logbin/mysql-bin.index' not found (OS errno 13 - Permission denied)
[root@master-DNS mysql]# cat /var/log/mysql/mysqld.log
2023-05-22T09:08:36.149861Z 0 [Warning] [MY-010918] [Server] 'default_authentication_plugin' is deprecated and will be removed in a future release. Please use authentication_policy instead.
2023-05-22T09:08:36.149902Z 0 [System] [MY-010116] [Server] /usr/libexec/mysqld (mysqld 8.0.32) starting as process 12540
mysqld: File '/data/mysql/logbin/mysql-bin.index' not found (OS errno 13 - Permission denied)
2023-05-22T09:08:36.152878Z 0 [ERROR] [MY-010119] [Server] Aborting
2023-05-22T09:08:36.153005Z 0 [System] [MY-010910] [Server] /usr/libexec/mysqld: Shutdown complete (mysqld 8.0.32)  Source distribution.

#解决方法是把/etc/my.cnf.d/mysql-server.cnf配置全部注释掉
[root@master-DNS logbin]# cat /etc/my.cnf.d/mysql-server.cnf 
#
# This group are read by MySQL server.
# Use it for options that only the server (but not clients) should see
#
# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/en/server-configuration-defaults.html

# Settings user and group are ignored when systemd is used.
# If you need to run mysqld under a different user or group,
# customize your systemd unit file for mysqld according to the
# instructions in http://fedoraproject.org/wiki/Systemd

#[mysqld]
#datadir=/var/lib/mysql
#socket=/var/lib/mysql/mysql.sock
#log-error=/var/log/mysql/mysqld.log
#pid-file=/run/mysqld/mysqld.pid
#server-id=234
#log-bin=/data/mysql/logbin/mysql-bin

#重新配置/etc/my.cnf
[root@master-DNS logbin]# cat /etc/my.cnf
#
# This group is read both both by the client and the server
# use it for options that affect everything
#
[client-server]

#
# include all files from the config directory
#
!includedir /etc/my.cnf.d
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
log-error=/var/log/mysql/mysqld.log
pid-file=/run/mysqld/mysqld.pid
server-id=234
log-bin=/data/mysql/logbin/mysql-bin

#创建存放二进制日志的目录
mkdir -p /data/mysql/logbin/
chown -R mysql.mysql /data

#重新启动即可成功
[root@master-DNS /]# systemctl restart mysqld.service
#检查日志
[root@master-DNS /]# ls -l /data/mysql/logbin/
total 16
-rw-r-----. 1 mysql mysql 180 May 22 17:13 mysql-bin.000001
-rw-r-----. 1 mysql mysql 180 May 22 17:21 mysql-bin.000002
-rw-r-----. 1 mysql mysql 157 May 22 17:21 mysql-bin.000003
-rw-r-----. 1 mysql mysql 108 May 22 17:21 mysql-bin.index