4)重置密码
[root@localhost ~]# grep 'temporary password' /var/log/mysqld.log|tail -n 1
2018-09-19T09:48:39.418109Z 1 [Note] A temporary password is generated for root@localhost: aBm<-wrj4NSV
[root@localhost ~]# mysqladmin -uroot -p'aBm<-wrj4NSV' password "Yanglt123."
mysqladmin: [Warning] Using a password on the command line interface can be insecure.
Warning: Since password will be sent to server in plain text, use ssl connection to ensure password safety.
[root@localhost ~]# systemctl restart mysqld
[root@localhost ~]#
5)恢复数据
[root@localhost ~]# mysql -uroot -p'Yanglt123.' < /tmp/2018-09-19-mysql-all.sql
mysql: [Warning] Using a password on the command line interface can be insecure.
[root@localhost ~]#
可以看到它恢复到了备份点,刚才创建的表t2是在备份点之后生成的,可以看到表中没有t2:
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| school |
| sys |
+--------------------+
5 rows in set (0.01 sec)
mysql> use school;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> show tables;
+------------------+
| Tables_in_school |
+------------------+
| t1 |
+------------------+
1 row in set (0.00 sec)
mysql>
6) 刷新授权
改完密码后与备份点的密码可能不一致,所有我们要执行此步骤,来实现与备份点密码一致。
[root@localhost ~]# mysql -p'Yanglt123.' -e 'flush privileges'
mysql: [Warning] Using a password on the command line interface can be insecure.
[root@localhost ~]#
7)建议在逻辑备份恢复时,暂停BINLOG
mysql> SET SQL_LOG_BIN=0;
Query OK, 0 rows affected (0.02 sec)
mysql> source /tmp/2018-09-19-mysql-all.sql;
Linux公社的RSS地址:https://www.linuxidc.com/rssFeed.aspx