当前位置:   article > 正文

阿里云Mysql5.7 数据库恢复 qp.xb文件恢复数据_数据库备份qp文件如何还原

数据库备份qp文件如何还原

1、宕下来的文件,一定是qp.xb的文件,如果不是qp.xb文件,该恢复文档不适合

2、准备linux系统,centos最好

3、centos 基础环境准备完之后安装必须要的恢复软件【基本按照官方文档即可】

        官网:RDS MySQL的物理备份如何恢复到自建数据库_云数据库 RDS-阿里云帮助中心

        安装Qpress

  1. #下载qoress 包,解压给予权限
  2. wget "http://docs-aliyun.cn-hangzhou.oss.aliyun-inc.com/assets/attach/183466/cn_zh/1608011575185/qpress-11-linux-x64.tar"
  3. tar xvf qpress-11-linux-x64.tar
  4. chmod 775 qpress
  5. cp qpress /usr/bin

       获取xtrabackup

wget https://www.percona.com/downloads/XtraBackup/Percona-XtraBackup-2.4.9/binary/redhat/7/x86_64/percona-xtrabackup-24-2.4.9-1.el7.x86_64.rpm

        网盘地址:

        链接:https://pan.baidu.com/s/1t57i7YtaTQg3LRVdPd0W6A 
        提取码:5ju4

       安装xtrabackup、mysql【mysql安装之后无需启动】

  1. #安装xtrabackup
  2. yum install -y percona-xtrabackup-24-2.4.9-1.el7.x86_64.rpm
  3. #安装mysql5.7系列
  4. wget -i -c http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm
  5. yum -y install mysql57-community-release-el7-10.noarch.rpm
  6. yum -y install mysql-community-server
  7. # rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022 如果报错,需要重新导入秘钥后再安装mysql-community-server

      Mysql5.7网盘地址:

                链接:https://pan.baidu.com/s/1j5W5qklQjxdLe1dXNXHJZQ 
                提取码:xa2a

        数据恢复:

  1. #将8p47w1251_qp.xb文件放置/opt目录下
  2. cd /opt
  3. #创建/home/mysql/data/文件夹
  4. mkdir -p /home/mysql/data
  5. #使用xbstream处理qp.xb文件
  6. cat 8p47w1251_qp.xb | xbstream -x -v -C /home/mysql/data
  7. #进入/home/mysql/data进行解压【跟着官网教程走】 显示 completed OK! 即正常
  8. cd /home/mysql/data/
  9. innobackupex --decompress --remove-original /home/mysql/data
  10. innobackupex --defaults-file=/home/mysql/data/backup-my.cnf --apply-log /home/mysql/data
  11. chown -R mysql:mysql /home/mysql/data

        修改mysql配置文件

  1. vim /home/mysql/data/backup-my.cnf
  2. #添加如下参数
  3. lower_case_table_names=1
  4. #注释如下不支持的参数:
  5. innodb_checksum_algorithm=crc32
  6. innodb_log_checksum_algorithm=strict_crc32
  7. innodb_data_file_path=ibdata1:200M:autoextend
  8. innodb_log_files_in_group=2
  9. innodb_log_file_size=1572864000
  10. innodb_fast_checksum=false
  11. innodb_page_size=16384
  12. innodb_log_block_size=512
  13. innodb_undo_directory=./
  14. innodb_undo_tablespaces=0
  15. server_id=1291154917
  16. redo_log_version=1
  17. server_uuid=dbd99726-2585-11eb-9ae1-78aa82d27dc0
  18. master_key_id=0
  19. innodb_encrypt_algorithm=AES_256_CBC

 启动mysql【知道数据库账号密码】

  1. #知道数据库账号、密码时
  2. mysqld --user=mysql --datadir=/home/mysql/data &
  3. #登陆
  4. mysql -u xxx -p

启动mysql【不知道数据库账号密码】

  1. #不知道数据库账号、密码时
  2. mysqld --user=mysql --datadir=/home/mysql/data --skip-grant-tables &
  3. #登陆,直接敲msyql 回车即可进入
  4. msyql

启动参数中加入 --skip-grant-tables启动数据库即可,使用root用户,可不需要密码直接登陆数据,但此时修改密码会由于触发器没有删除造成无法修改,“Unknown trigger has an error in its body: 'Unknown system variable 'maintain_user”;

  1. mysql> select trigger_schema,trigger_name from information_schema.triggers;
  2. +----------------+----------------------------+
  3. | trigger_schema | trigger_name |
  4. +----------------+----------------------------+
  5. | sys | sys_config_insert_set_user |
  6. | sys | sys_config_update_set_user |
  7. +----------------+----------------------------+
  8. 2 rows in set (0.03 sec)
  9. mysql> drop trigger sys.sys_config_insert_set_user;
  10. Query OK, 0 rows affected (0.06 sec)
  11. mysql> drop trigger sys.sys_config_update_set_user;
  12. Query OK, 0 rows affected (0.02 sec)

所以在启动前处理触发器

  1. #查找触发器文件,并删除/移动
  2. find /home/mysql/data/ -iname *.trg
  3. /home/mysql/data/mysql/proxies_priv.TRG
  4. /home/mysql/data/mysql/user.TRG
  5. mv /home/mysql/data/mysql/user.TRG /home/mysql/data/mysql/user.TRG.back
  6. mv /home/mysql/data/mysql/proxies_priv.TRG /home/mysql/data/mysql/proxies_priv.TRG.back

退出mysql,重启mysql后【启动参数加--skip-grant-tables】,进入

  1. [root@localhost ~]# mysql
  2. Welcome to the MySQL monitor. Commands end with ; or \g.
  3. Your MySQL connection id is 4
  4. Server version: 5.7.30 MySQL Community Server (GPL)
  5. Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
  6. Oracle is a registered trademark of Oracle Corporation and/or its
  7. affiliates. Other names may be trademarks of their respective
  8. owners.
  9. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
  10. mysql> use mysql;
  11. Reading table information for completion of table and column names
  12. You can turn off this feature to get a quicker startup with -A
  13. Database changed
  14. mysql> update mysql.user set authentication_string = password('新的密码') where user='用户名' and host='%';
  15. Query OK, 1 row affected, 1 warning (0.02 sec)
  16. Rows matched: 1 Changed: 1 Warnings: 1
  17. mysql> flush privileges;
  18. Query OK, 0 rows affected (0.00 sec)

退出,重启mysql【启动参数去掉--skip-grant-tables】,使用用户密码登录

mysql -u xxx -p

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/爱喝兽奶帝天荒/article/detail/811356?site
推荐阅读
相关标签
  

闽ICP备14008679号