вторник, 27 марта 2012 г.

Mysql backup/restore

Просто положу здесь.

Use of mysqldump for taking backup of one table

In this section you will see the example of mysqldump function which takes the backup of only one table.

The mysqldump utility provides many options to take the backup of data as per user requirement. You can specify the name of table be backup in while executing the mysqldump utility.

Let's assume we have to take the backup of table1 from the mydatabase, then you can issue the following command on the console:

mysqldump -u -p mydatabase table1 > table1.sql

To restore the backup you can use the following command:

mysql -u -p mydatabase < table1.sql The mysqldump is very handy tool, it can be easily used to take the backup of only one table from the database. --- Dump ALL MySQL Databases mysqldump --user=XXXXXXXX --password=XXXXXXX -A > /PATH/TO/DUMPFILE.SQL

Dump Individual or Multiple MySQL Databases
mysqldump --user=XXXXXXXX --password=XXXXXXX --databases DB_NAME1 DB_NAME2 DB_NAME3 > /PATH/TO/DUMPFILE.SQL

Dump only certain tables from a MySQL Database
mysqldump --user=XXXXXXXX --password=XXXXXXXX --databases DB_NAME --tables TABLE_NAME > /PATH/TO/DUMPFILE.SQL

Use the following procedure to reload the contents of a database:
1. Unzip the backup file you wish to use.
2. Open it up and pull out only the information that you will need.
3. Save this text file.
4. Use the following command to feed back in the contents of a text file:
mysql --verbose --user=XXXXXXXX --password=XXXXXXXX DB_NAME < /PATH/TO/DUMPFILE.SQL

Комментариев нет:

Отправить комментарий