Home > Database > Mysql Tutorial > How to restore files created by mysqldump?

How to restore files created by mysqldump?

WBOY
Release: 2023-09-09 12:01:02
forward
1413 people have browsed it

如何恢复 mysqldump 创建的文件?

Suppose we want to restore a file created by mysqldump, then we can restore it in the existing database, or we can restore it in a new database after creating the file. Then with the help of the SOURCE statement, we can restore it. We can illustrate with an example:

Example

In this example, we are restoring the dumped student_info.sql named. It's basically in the database name "query". Now we restore it to a database called "tutorials".

mysql> Use Tutorials;
Database changed

mysql> SOURCE student_info.sql;
Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected, 1 warning (0.00 sec)

Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.45 sec)

Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.05 sec)

Query OK, 0 rows affected (0.00 sec)

Query OK, 7 rows affected (0.05 sec)
Records: 7 Duplicates: 0 Warnings: 0
Copy after login

Now, with the help of the following statement, we can see that the "student_info" table has been restored to the database named "Tutorials".

mysql> Show tables;
+---------------------+
| Tables_in_tutorials |
+---------------------+
| rtgs                |
| student_info        |
+---------------------+
2 rows in set (0.00 sec)

mysql> Select * from Student_info;
+------+---------+------------+------------+
| id   | Name    | Address    | Subject    |
+------+---------+------------+------------+
| 101  | YashPal | Amritsar   | History    |
| 105  | Gaurav  | Chandigarh | Literature |
| 125  | Raman   | Shimla     | Computers  |
| 130  | Ram     | Jhansi     | Computers  |
| 132  | Shyam   | Chandigarh | Economics  |
| 133  | Mohan   | Delhi      | Computers  |
| 150  | Saurabh | NULL       | Literature |
+------+---------+------------+------------+
7 rows in set (0.00 sec)
Copy after login

The above is the detailed content of How to restore files created by mysqldump?. For more information, please follow other related articles on the PHP Chinese website!

source:tutorialspoint.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template