项目场景:

是这样的,我一个系统部署在腾讯云服务器,安装的的centos 3.10.0-123.el7.x86_64系统,被黑了,经过各种折腾我把数据拷贝到另一个磁盘了,言归正传,本文在记录的就是,在恢复mysql数据时遇到的一个问题。


问题描述:

目前已得知我的数据库数据已经拿到了,我只需要修改下数据库配置文件datadir 即可,就在已经准备好了,启动mysql启动失败。

[root@VM-0-12-centos yudao-sword]# service mysqld start
Redirecting to /bin/systemctl start mysqld.service
Job for mysqld.service failed because the control process exited with error code. See "systemctl status mysqld.service" and "journalctl -xe" for details.

原因分析:

查看mysql服务状态

[root@VM-0-12-centos yudao-sword]# service mysqld status
Redirecting to /bin/systemctl status mysqld.service
● mysqld.service - MySQL Server
   Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
   Active: failed (Result: start-limit) since Sat 2022-03-05 18:40:49 CST; 3min 12s ago
     Docs: man:mysqld(8)
           http://dev.mysql.com/doc/refman/en/using-systemd.html
  Process: 13305 ExecStart=/usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid $MYSQLD_OPTS (code=exited, status=1/FAILURE)
  Process: 13287 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
 Main PID: 1754 (code=exited, status=0/SUCCESS)

Mar 05 18:40:49 VM-0-12-centos systemd[1]: Failed to start MySQL Server.
Mar 05 18:40:49 VM-0-12-centos systemd[1]: Unit mysqld.service entered failed state.
Mar 05 18:40:49 VM-0-12-centos systemd[1]: mysqld.service failed.
Mar 05 18:40:49 VM-0-12-centos systemd[1]: mysqld.service holdoff time over, scheduling restart.
Mar 05 18:40:49 VM-0-12-centos systemd[1]: start request repeated too quickly for mysqld.service
Mar 05 18:40:49 VM-0-12-centos systemd[1]: Failed to start MySQL Server.
Mar 05 18:40:49 VM-0-12-centos systemd[1]: Unit mysqld.service entered failed state.
Mar 05 18:40:49 VM-0-12-centos systemd[1]: mysqld.service failed.

查看系统日志:journalctl -xe

在这里插入图片描述

数据库数据文件(datadir)夹权限问题

从系统日志不难看出是权限问题原因,那我们看下文件权限在这里插入图片描述
确实是,因为这个mysql_recovery是我用root权限创建的。


解决方案:

既然找到是目录权限问题,那么解决方法有两个。
1、mysql_recovery文件夹的所有内容授权给另mysql用户。
chown -R mysql mysql_recovery
2、mysql_recovery目录权限设置为777
chown -R 777 mysql_recovery

结果

在这里插入图片描述

Logo

更多推荐