1. About.com
  2. Computing & Technology
  3. PHP / MySQL

Discuss in my forum

Backup and Restore MySQL Databases

By , About.com Guide

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

©2012 About.com. All rights reserved. 

A part of The New York Times Company.