I have a testDBbackup.sql file. I dropped the mysql database a while back and I was wondering how I could restore it from my backup file. I am using a Mac. I was hoping somebody could show me how to do it from the command line, unless there is an easier way from the file system or something.
Asked
Active
Viewed 1.2k times
2 Answers
12
If your file contains the database create code and that is not conflicting with existing databases. Just go with.
mysql -u root -p
-- You'll be prompted for password
mysql> source filename.sql
If database with a given name already exists and you only want to dump data into it via terminal.
mysql -u root -p testdb < filename.sql
-- You'll be prompted for password
If you have to create it and then dump
mysql -u root -p
-- You'll be prompted for password
mysql> create database test;
mysql> source filename.sql
Make sure you replace root
with your actual user, testdb
with your database name and filename
with actual file.

Dark Knight
- 6,116
- 1
- 15
- 37
1
On your localhost server find phpmyadmin
.
- Generate an empty database
- Perform import from your testDBbackup.sql file
Note that if testDBbackup.sql
is large you can ZIP it.

Mulli
- 1,598
- 2
- 22
- 39