1. Computing

Backup and Restore MySQL Databases

By

2 of 4

Restore Database From the Command Prompt
If you are moving your data to a new server, or you have removed the old database completely you can restore it using the code below. This will only work if the database does not already exist:

mysql - u user_name -p your_password database_name < file_name.sql

Or using our example from the previous page:

mysql - u bobbyjoe -p happy234 BobsData < BobBackup.sql
If your database already exists and you are just restoring it, try this line instead:

mysqlimport -u user_name -p your_password database_name file_name.sql

Or using our example again:

mysqlimport -u bobbyjoe -p happy234 BobsData BobBackup.sql
Related Video
Restore a Discolored Photo in Photoshop Elements
How to Create a PHP Calendar
  1. About.com
  2. Computing
  3. PHP / MySQL
  4. Learn MySQL
  5. Restore a MySQL database from the command prompt

©2014 About.com. All rights reserved.