-->

Type something and hit enter

On
advertise here

 

Backing Up And Restoring Your MySQL Database

bacaartikeldisiniaja -- If you are using MySQL database to store important data, it is essential to back up your data to prevent data loss. This article describes how to back up and restore data in MySQL databases. This process can also be used when data needs to be moved to a new server.


Back up your database

The quickest and easiest way to back up and restore your database is with MySQLDump. If you have shell or telnet access to your server, you can run the mysqldump command to back up your MySQL data. The command syntax is:


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


To back up the "customers" database to the file custback.sql with username "sadmin" and password "pass21", enter the following command:


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

Issuing this command backs up the database to custback.sql. You can copy and store this file in a safe place or on backup media. For more information on MySQLDump see:


http://www.mysql.com/doc/en/mysqldump.html


Restore the database

If you need to create the database from scratch, you can easily restore the mysqldump file by running: This method will not work if the table already exists in the database. mysql -u sadmin -p pass21 customer < custback.sql


If you need to restore an existing database, you should use MySQLImport. The syntax for mysqlimport is:


mysqlimport [options] database textfile1

To restore the previously created custback.sql dump to the customer database, print:

mysqlimport -u sadmin -p pass21 customer custback.sql



Click to comment