Computer >> Hướng Dẫn Máy Tính >  >> Lập Trình >> MySQL

Khôi phục file dump mysqldump bằng lệnh SOURCE

Quy trình khôi phục

  1. Tạo database đích (nếu chưa có) và USE nó.
  2. Chạy lệnh SOURCE path/to/dump_file.sql; trong client MySQL.

Ví dụ

Khôi phục student_info.sql (dump từ DB query) vào DB tutorials:

mysql> USE Tutorials;
Database changed
mysql> SOURCE student_info.sql;
Query OK, 0 rows affected ... (nhiều dòng)
Query OK, 7 rows affected (0.05 sec)
Records: 7 Duplicates: 0 Warnings: 0

Kiểm tra:

mysql> SHOW TABLES;
+---------------------+
| Tables_in_tutorials |
+---------------------+
| rtgs                |
| student_info        |
+---------------------+

mysql> SELECT * FROM Student_info;
+------+---------+------------+------------+
| id   | Name    | Address    | Subject    |
+------+---------+------------+------------+
| 101  | YashPal | Amritsar   | History    |
| 150  | Saurabh | NULL       | Literature |
+------+---------+------------+------------+