mysql-阿里云mysql数据备份恢复踩的坑

0. 阿里云官方 参考链接:https://help.aliyun.com/knowledge_detail/41817.html

  • 大家可以先按照阿里云官方的来,如果发现有地方卡住了再来看我的操作教程~~

1. 下载备份实例

2. 解压备份实例

3. 命令恢复备份数据

innobackupex --defaults-file=/home/mysql/data/backup-my.cnf --apply-log /home/mysql/data

4. 注释掉备份数据中.cnf中的部分数据

  • ps: 特别注意,如果不能成功启动,特别有可能是因为有一些参数你没有注释掉
vi /home/mysql/data/backup-my.cnf

5. 一定要记得将这个文件夹下的数据授权给mysql

chown -R mysql:mysql /home/mysql/data

6. 启动mysql

  • ps: 如果提示无法找到mysqld_safe,可以直接用mysqld启动
mysqld_safe --defaults-file=/home/mysql/data/backup-my.cnf --user=mysql --datadir=/home/mysql/data &
  • ps: 启动出现报错如下
2019-08-28T02:03:41.175708Z 0 [ERROR] InnoDB: Unable to lock ./ibdata1 error: 11
2019-08-28T02:03:41.175728Z 0 [Note] InnoDB: Check that you do not already have another mysqld process using the same InnoDB data or log files.
  1. 出现这个问题的原因是因为有其他mysql进程在使用ibdata1这个文件,用ps -ef | grep mysql 找到相应进程kill掉。但是基本mysql都是有自动设置的,所以如果是自己启动失败的可以用Kill如果是自启动的mysql建议用 service mysqld stop
  • ps: 报错 Failed to open the relay log
2019-08-28T02:03:48.322431Z 0 [ERROR] Failed to open the relay log '/home/mysql/data3066/mysql/slave-relay.005628' (relay_log_pos 12018289).
2019-08-28T02:03:48.322443Z 0 [ERROR] Could not find target log file mentioned in relay log info in the index file './localhost-relay-bin.index' during relay log initialization.
2019-08-28T02:03:48.323166Z 0 [ERROR] Slave: Failed to initialize the master info structure for channel ''; its record may still be present in 'mysql.slave_master_info' table, consider deleting it.
2019-08-28T02:03:48.323182Z 0 [ERROR] Failed to create or recover replication info repositories.
  1. 找到/home/mysql/data 下的 localhost-relay-bin.*所有的文件进行删除操作 rm -rf localhost-relay-bin.*
  2. 删除rm master.info(这个不确定)

备注

  • 启动mysql的时候要先把服务器上的mysql停止
service mysqld start
service mysqld stop
systemctl status mysqld.service 查看mysql服务状态
  • 登录命令的账号密码就是你原先备份数据库用的那个账户密码
  • 每次启动完后试试mysql命令看看是不是启动成功了,因为那个启动命令也没找到启动成功有什么提示(warning没事,感觉是不出现error就算是启动成功了)
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值