一 问题描述
1.1 问题描述
首先通过切换到mysql数据库所属用户: hd-mysql
[root@localhost local]# su hd-mysql
2.启动mysql,报错
[hd-mysql@localhost data]$ service mysql start
Starting MySQL. ERROR! The server quit without updating PID file (/home/hd-mysql/mysql-5.7.32/data/localhost.localdomain.pid).
二 解决办法
2.1 查看错误日志
进入到/home/hd-mysql/mysql-5.7.32/data 目录下,查看 以xxx.err结尾文件
查看内容
[hd-mysql@localhost data]$ more localhost.localdomain.err 2022-12-29T03:36:37.267121Z mysqld_safe Logging to '/home/hd-mysql/mysql-5.7.32/data/localhost.localdomain.err'. 2022-12-29T03:36:37.282396Z mysqld_safe Starting mysqld daemon with databases from /home/hd-mysql/mysql-5.7.32/data 2022-12-29T03:36:37.289659Z 0 [Warning] Changed limits: max_open_files: 1024 (requested 5000) 2022-12-29T03:36:37.289748Z 0 [Warning] Changed limits: table_open_cache: 431 (requested 2000) 2022-12-29T03:36:37.495033Z 0 [Note] --secure-file-priv is set to NULL. Operations related to importing and exporting data are disabled 2022-12-29T03:36:37.495083Z 0 [Note] /home/hd-mysql/mysql-5.7.32/bin/mysqld (mysqld 5.7.32-log) starting as process 5222 ... mysqld: File './master-bin.index' not found (Errcode: 13 - Permission denied) 2022-12-29T03:36:37.507912Z 0 [ERROR] Aborting 2022-12-29T03:36:37.507962Z 0 [Note] Binlog end 2022-12-29T03:36:37.508016Z 0 [Note] /home/hd-mysql/mysql-5.7.32/bin/mysqld: Shutdown complete |
可以看到权限问题:
第一行的错误提示,errcode13,一般就是权限问题,mysql用户是否对数据库目录内的所有文件具有写的权限
3.查看mysql的安装目录
可以看到data目录下,有些文件的的权限隶属于root用户!
2.2 解决处理
1.切换到root用户,赋予mysql安装目录的所属hd-mysq用户的权限
chown -R hd-mysql:hd-mysql /home/hd-mysql/
2.查看现在文件目录隶属用户,可以看到现在已经隶属于hd-mysql用户
3.切换到hd-mysql用户,进行启动mysql
现在问题得到解决!
来源地址:https://blog.csdn.net/u011066470/article/details/128480494