1. Home
  2. Computing & Technology
  3. PHP / MySQL

Backup and Restore MySQL Databases

By , About.com Guide

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
Explore PHP / MySQL
About.com Special Features

Holiday Central

What to eat, where to go, fun things to do and how to save money on the perfect gifts. More >

Family Tech Center

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

  1. Home
  2. Computing & Technology
  3. PHP / MySQL
  4. Learn MySQL
  5. Restore MySQL - Restore Database - Upload MySQL

©2009 About.com, a part of The New York Times Company.

All rights reserved.