1. 程式人生 > >用mydump對所有資料庫進行備份,還原具體案例

用mydump對所有資料庫進行備份,還原具體案例

現有的測試資料:

對所有資料庫做備份:

C:\Users\Administrator>mysqldump -u root -p --all-databases> D:\mysql_bak\201409111654_all_database.bak

Enter password: *******

刪除jiaodan_test資料庫裡t表的資料:

匯入檔案進行恢復:

C:\Users\Administrator>mysql -u root -p < D:\mysql_bak\201409111654_all_database

.bak

Enter password: *******

C:\Users\Administrator>mysql -u root -p

Enter password: *******

Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 55

Server version: 5.5.21 MySQL Community Server (GPL)

Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its

affiliates. Other names may be trademarks of their respective

owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> use dan_test;

Database changed

mysql> select *

    -> from t;

+------+

| id   |

+------+

|    1 |

|    2 |

+------+

2 rows in set (0.00 sec)

mysql> use jiao;

Database changed

mysql> select *

    -> from t;

+------+

| id   |

+------+

|    1 |

+------+

1 row in set (0.00 sec)

mysql>