MySQL
  Home arrow MySQL arrow Page 3 - Backing Up and Restoring Your MySQL Da...
Dev Shed Forums 
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Forums Sitemap 
IBM® developerWorks 
Sun Developer Network 
Dedicated Servers 
E-Commerce Hosting 
Linux Web Hosting 
Managed Hosting 
Small Business Hosting 
Actuate Whitepapers 
VeriSign Whitepapers 
VPS Hosting 
Weekly Newsletter

 
Developer Updates  
Free Website Content 
IBM developerWorks
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
MYSQL

Backing Up and Restoring Your MySQL Database
By: Vinu Thomas
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 293
    2004-06-15

    Table of Contents:
  • Backing Up and Restoring Your MySQL Database
  • What about Multiple Databases?
  • Easy Restore
  • PHPMyAdmin
  • Backing Up and Restoring Your Database with PHPMyAdmin

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT

    Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here

    Backing Up and Restoring Your MySQL Database - Easy Restore


    (Page 3 of 5 )

    Now that you've got backups of your database, let's learn how to restore your backup in case your database goes down. Here's how you can restore your backed up database using the mysql command.

    Restore using mysql

    If you have to re-build your database from scratch, you can easily restore the mysqldump file by using the mysql command. This method is usually used to recreate or rebuild the database from scratch.

    Here's how you would restore your custback.sql file to the Customers database.

    mysql -u sadmin -p pass21 Customers < custback.sql

    Easy isn't it ? Here's the general format you would follow:

    mysql -u [username] -p [password] [database_to_restore] < [backupfile]

    Now how about those zipped files? You can restore your zipped backup files by first uncompressing its contents and then sending it to mysql.

    gunzip < custback.sql.sql.gz | mysql -u sadmin -p pass21 Customers

    You can also combine two or more backup files to restore at the same time, using the cat command. Here's how you can do that.

    cat backup1.sql backup.sql | mysql -u sadmin -p pass21

    Moving Data Directly Between Databases

    How would you like to replicate your present database to a new location? When you are shifting web hosts or database servers, you can directly copy data to the new database without having to create a database backup on your machine and restoring the same on the new server. mysql allows you to connect to a remote database server to run sql commands. Using this feature, we can pipe the output from mysqldump and ask mysql to connect to the remote database server to populate the new database. Let's say we want to recreate the Customers database on a new database server located at 202.32.12.32, we can run the following set of commands to replicate the present database at the new server.

    mysqldump -u sadmin -p pass21 Customers | mysql --host=202.32.12.32 -C Customers

    More MySQL Articles
    More By Vinu Thomas


       · This article easy very good for beginners and also for professionals for quick...
       · Thank You, but in this case i want to ask ...How to backup database but the output...
       · Hi Its very good and excellent explanation about backup and...
     

       

    MYSQL ARTICLES

    - MySQL Table Prefix Changer Tool in PHP
    - Using the SIGNAL Statement for Error Handling
    - Error Handling Examples
    - Error Handling
    - Completing a Search Engine with MySQL and PH...
    - Paginating Result Sets for a Search Engine B...
    - Building a Search Engine with MySQL and PHP 5
    - Using Boolean Operators for Full Text and Bo...
    - PHP, MySQL and the PEAR Database
    - Working with PHP and MySQL
    - Getting PHP to Talk to MySQL
    - Creating an RSS Reader: the Reader
    - MySQL Security Overview
    - Creating the Admin Script for a PHP/MySQL Bl...
    - Creating the Blog Script for a PHP/MySQL Blo...





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway