xuol001 发表于 2018-10-3 09:47:28

MySQL的备份、还原及恢复

mysql> insert into shop.ecs_users(user_name,last_time) values ('user1',now());  
Query OK, 1 row affected, 7 warnings (0.03 sec)
  
mysql> select user_id,user_name,last_time from shop.ecs_users;
  
+---------+-----------+---------------------+
  
| user_id | user_name | last_time         |
  
+---------+-----------+---------------------+
  
|       1 | ecshop    | 0000-00-00 00:00:00 |
  
|       2 | vip       | 0000-00-00 00:00:00 |
  
|       3 | text      | 0000-00-00 00:00:00 |
  
|       5 | zuanshi   | 0000-00-00 00:00:00 |
  
|       6 | user1   | 2013-08-17 20:58:40 |
  
+---------+-----------+---------------------+
  
5 rows in set (0.02 sec)
  
再插入1条:
  
mysql> insert into shop.ecs_users(user_name,last_time) values ('user2',now());
  
Query OK, 1 row affected, 7 warnings (0.00 sec)
  
mysql> select user_id,user_name,last_time from shop.ecs_users;
  
+---------+-----------+---------------------+
  
| user_id | user_name | last_time         |
  
+---------+-----------+---------------------+
  
|       1 | ecshop    | 0000-00-00 00:00:00 |
  
|       2 | vip       | 0000-00-00 00:00:00 |
  
|       3 | text      | 0000-00-00 00:00:00 |
  
|       5 | zuanshi   | 0000-00-00 00:00:00 |
  
|       6 | user1   | 2013-08-17 20:58:40 |
  
|       7 | user2   | 2013-08-17 21:01:59 |
  
+---------+-----------+---------------------+
  
6 rows in set (0.00 sec)
  
mysql> show master status;
  
+------------------+----------+--------------+------------------+
  
| File             | Position | Binlog_Do_DB | Binlog_Ignore_DB |
  
+------------------+----------+--------------+------------------+
  
| mysql-bin.000019 |   1225 |            |                  |
  
+------------------+----------+--------------+------------------+
  
1 row in set (0.00 sec)
  
滚动二进制日志后再插入几条:
  
mysql> flush logs;
  
Query OK, 0 rows affected (0.12 sec)
  
mysql> show master status;
  
+------------------+----------+--------------+------------------+
  
| File             | Position | Binlog_Do_DB | Binlog_Ignore_DB |
  
+------------------+----------+--------------+------------------+
  
| mysql-bin.000020 |      107 |            |                  |
  
+------------------+----------+--------------+------------------+
  
1 row in set (0.00 sec)
  
mysql> insert into shop.ecs_users(user_name,last_time) values ('user3',now()),('user4',now()),('user5',now());
  
Query OK, 3 rows affected, 7 warnings (0.00 sec)
  
Records: 3Duplicates: 0Warnings: 7
  
mysql> select user_id,user_name,last_time from shop.ecs_users;
  
+---------+-----------+---------------------+
  
| user_id | user_name | last_time         |
  
+---------+-----------+---------------------+
  
|       1 | ecshop    | 0000-00-00 00:00:00 |
  
|       2 | vip       | 0000-00-00 00:00:00 |
  
|       3 | text      | 0000-00-00 00:00:00 |
  
|       5 | zuanshi   | 0000-00-00 00:00:00 |
  
|       6 | user1   | 2013-08-17 20:58:40 |
  
|       7 | user2   | 2013-08-17 21:01:59 |
  
|       8 | user3   | 2013-08-17 21:04:50 |
  
|       9 | user4   | 2013-08-17 21:04:50 |
  
|      10 | user5   | 2013-08-17 21:04:50 |
  
+---------+-----------+---------------------+
  
9 rows in set (0.00 sec)
  
mysql> show master status;
  
+------------------+----------+--------------+------------------+
  
| File             | Position | Binlog_Do_DB | Binlog_Ignore_DB |
  
+------------------+----------+--------------+------------------+
  
| mysql-bin.000020 |      449 |            |                  |
  
+------------------+----------+--------------+------------------+
  
1 row in set (0.00 sec)
  
mysql> flush logs;
  
Query OK, 0 rows affected (0.12 sec)


页: [1]
查看完整版本: MySQL的备份、还原及恢复