RLROUSE Directory & Informational Resources
Home     Add URL     Edit Listing     Infoblog     Picture of the Day     Privacy Policy     Advertise     About us     Write for us     Contact us     Sitemap


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. He invites you to visit him at http://vinuthomas.com.

More Interesting Articles

Home     Add URL     Infoblog     Privacy Policy     Advertise     About us     Write for us     Report a broken link     Contact us     Sitemap
Copyright 2003-2017 RLROUSE.COM

RLROUSE.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program
designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com.