[root@sc-mysql backup]# mysql -uroot -p'Sanchuang123#' < sanchuang.sql
mysql: [Warning] Using a password on the command line interface can be insecure.
[root@sc-mysql backup]#
第2步:查看二进制日志找到删除数据库之前的position 位置号
[root@sc-mysql mysql]# mysqlbinlog -v sc-mysql-bin.000005|egrep -C 5 "drop database"#210401 10:42:39 server id 1 end_log_pos 1063 CRC32 0x8623d686 Anonymous_GTID last_committed=3 sequence_number=4 rbr_only=no
SET @@SESSION.GTID_NEXT='ANONYMOUS'/*!*/;# at 1063#210401 10:42:39 server id 1 end_log_pos 1170 CRC32 0xf9eee347 Query thread_id=14 exec_time=0 error_code=0
SET TIMESTAMP=1617244959/*!*/;
drop database sanchuang
/*!*/;# at 1170#210401 10:44:13 server id 1 end_log_pos 1235 CRC32 0xa92ef3c4 Anonymous_GTID last_committed=4 sequence_number=5 rbr_only=no
SET @@SESSION.GTID_NEXT='ANONYMOUS'/*!*/;# at 1235[root@sc-mysql mysql]#
第3步:使用二进制日志去恢复
[root@sc-mysql mysql]# mysqlbinlog --start-position=154 --stop-position=1063 sc-mysql-bin.000005|mysql -uroot -p'Sanchuang123#'
mysql: [Warning] Using a password on the command line interface can be insecure.
[root@sc-mysql mysql]#