RLROUSE Directory & Informational Resources
 

Add URL  -  Site Map
  Home
  Add URL
  SEO Toolkit
 

  Webmaster / SEO Info
  Featured Stores
  Featured Text Listings
  Birdhouses
  Birdfeeders
  Great Recipes

  Articles
       ->Personal Finance
       ->Birding
       ->Crafts
       ->Lawn & garden
       ->Webmaster
       ->PC technology
       ->Steps to success
       ->Travel
       ->Your health
       ->The 50 US states
       ->Bluegrass music
       ->Picture of the day
       ->Submit article

 Freebies

  Privacy policy
  Contact us
  Link to us
  Newsletter
  About us
  Recommend
  Advertise with us

  Site map 

   

Backing Up And Restoring A MySQL Database

How to safeguard your MySQL data



If you use a MySQL database to store your precious data, it is very important that you make regular backups of your data to protect it from loss. This article will show you how to backup and restore the data in your MySQL database. You can also use this process to move your data to a new server. 

Backing up your MySQL database 

The fastest and easiest method to backup and restore your MySQL database is to use MySQLDump. If you have shell or telnet access to your web server, you can backup your MySQL data with the mysqldump command. Here is the proper syntax: 

mysqldump -u [uname] -p [pass] [dbname] > [backupfile.sql] [uname] - this is your database username [pass]- this is the password for your database [dbname] - the name of your database [backupfile.sql] - the filename for your database backup

To backup a database named 'Customers' with the username 'sadmin' and the password 'pass21' to a file custback.sql, you would issue this command:

mysqldump -u sadmin -p pass21 Customers > custback.sql

Issuing that command will backup the MySQL database 'Customers' to a file called custback.sql. This file can then be copied to a safe location or stored on backup media.

Restoring your MySQL database

In the event that you need to re-build your MySQL database from scratch, you can easily restore the mysqldump file created above by issuing the following command (this method won't work if the tables already exist in your database):

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

If you need to restore a database that already exists, you'll need to use MySQLImport. The proper syntax for mysqlimport is:

mysqlimport [options] database textfile1

To restore your previously created custback.sql dump back to your 'Customers' MySQL database, you'd use:

mysqlimport -u sadmin -p pass21 Customers custback.sql
 

About the author:

Vinu Thomas is a web design and IT consultant. You can visit him at http://www.vinuthomas.com or discuss this article or any PHP/MYSQL related issues in our Discussion Forums at http://www.vinuthomas.com/forum2.html.


More Interesting Articles

 



 
 


 
 
© 2003-2009 RLROUSE.COM, Abingdon, Va Home