数据库备份

数据库备份:

安装xtraBackup包

网址:
https://www.percona.com/downloads/XtraBackup/LATEST/
安装

[root@localhost ~]# wget https://www.percona.com/downloads/XtraBackup/Percona-XtraBackup-2.4.4/binary/redhat/7/x86_64/percona-xtrabackup-24-2.4.4-1.el7.x86_64.rpm
[root@localhost ~]# yum localinstall percona-xtrabackup-24-2.4.4-1.el7.x86_64.rpm

1、完全备份

1)创建完全备份的目录

[root@localhost ~]# mkdir /xtrabackup/full -p

2)备份

[root@localhost ~]# innobackupex --user=root --password='Www.2.com' /xtrabackup/full

3)恢复
停止数据库

[root@localhost ~]# systemctl stop mysqld.service 

清理环境

[root@localhost ~]# rm -rf /var/lib/mysql/*
可不清理
[root@localhost ~]# rm -rf /var/log/mysqld.log 
[root@localhost ~]# rm -rf /var/log/mysql-slow/slow.log 

恢复

[root@localhost ~]#innobackupex --apply-log /xtrabackup/full/2019-02-12_20-04-22/
[root@localhost ~]#innobackupex --copy-back /xtrabackup/full/2019-02-12_20-04-22/

权限设置

[root@localhost ~]# chown -R mysql.mysql /var/lib/mysql

启动

[root@localhost ~]# systemctl start mysqld

你可能感兴趣的:(数据库备份)