
- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How can I restore a file created by mysqldump?
Suppose if we want to restore a file that has been created by mysqldump then we can restore in an existing database or in a new database after creating it. Then with the help of SOURCE statement, we can restore it. We can illustrate it by an example:
Example
In this example, we are restoring the table named student_info.sql which has been dumped. It was basically in the database name ‘query’. Now we will restore it into a database named ‘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
Now, with the help of the following statement, we can see that ‘student_info’ table is restored in a 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)
- Related Questions & Answers
- How can I restore a database dumped by mysqldump?
- How can I restore multiple databases or all databases dumped by mysqldump?
- How can I restore the MySQL root user full privileges?
- When can a .class file get created in Java?
- How can we take a backup of multiple databases by using mysqldump client program?
- How can I source a Python file from another Python file?
- How do I access values created by serializeArray in jQuery?
- How can we take a backup of the single database by using mysqldump client program?
- How can we take a backup of all the databases by using mysqldump client program?
- How can we take a backup of a particular table from a database by using mysqldump client program?
- Restore deleted file and folder shortcuts in windows
- How can I open a VDS file with three js?
- How can I download a file on a click event using selenium?
- How can I get a file's size in C++?
- How can we check the indexes created by a UNIQUE constraint on a MySQL table?
Advertisements