2

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.

2 Answers2

3

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
  • 5,626
  • 1
  • 11
  • 32
0

On your localhost server find phpmyadmin.

  1. Generate an empty database
  2. Perform import from your testDBbackup.sql file

Note that if testDBbackup.sql is large you can ZIP it.

Mulli
  • 1,434
  • 1
  • 21
  • 36