MySQL backup and Restoration

Source: Internet
Author: User
Tags mysql backup

MySQL Database Backup Using mysqldump command.
Tuesday, January 20,200 9, how-to, MySQL 195 views add a comment since its release in 1995, MySQL has became one of the most commonly used database in Internet world. A lot of small and medium businesses uses MySQL as their backend dB. its popularity for use with Web applications is closely tied to the popularity of PHP, which is often combined with MySQL. wikipedia runs on mediawiki software, which is written in PHP and uses a MySQL database. several high-traffic web sites use MySQL for its data storage and logging of user data, including Flickr, Facebook, Wikipedia, Google, Nokia and YouTube.

MySQL provide a great command line utility to take backup of your MySQL database and restore it. mysqldump command line utility is available with MySQL installation (bin directory) that can be used to achieve this.

1. Getting backup of a MySQL database using mysqldump.
Use following command line for taking backup of your MySQL database using mysqldump utility.

View plaincopy to clipboardprint?

Mysqldump -- User [user name] -- Password = [Password] [database name]> [dump file]

Or

Mysqldump-U [user name]-P [Password] [database name]> [dump file]

Mysqldump -- User [user name] -- Password = [Password] [database name]> [dump file]

Or

Mysqldump-U [user name]-P [Password] [database name]> [dump file]
Example:

View plaincopy to clipboardprint?

Mysqldump -- User Root -- Password = myrootpassword db_test> db_test. SQL

Or

Mysqldump-uroot-pmyrootpassword db_test> db_test. SQL

Mysqldump -- User Root -- Password = myrootpassword db_test> db_test. SQL

Or

Mysqldump-uroot-pmyrootpassword db_test> db_test. SQL
2. Backup Multiple databases in MySQL.
View plaincopy to clipboardprint?

Mysqldump-U [user name]-P [Password] [database name 1] [database name 2]...> [dump file]

Mysqldump-U [user name]-P [Password] [database name 1] [database name 2]...> [dump file]
Example:

View plaincopy to clipboardprint?

Mysqldump -- User Root -- Password = myrootpassword db_test db_second db_third> db_test. SQL

Mysqldump -- User Root -- Password = myrootpassword db_test db_second db_third> db_test. SQL
3. Backup all databases in MySQL.
View plaincopy to clipboardprint?

Shell> mysqldump-U [user name]-P [Password]-All-databases> [dump file]

Shell> mysqldump-U [user name]-P [Password]-All-databases> [dump file]
4. Backup a specific table in MySQL.
View plaincopy to clipboardprint?

Shell> mysqldump -- User [username] -- Password = [Password] [database name] [Table name] \
>/Tmp/sugarcrm_accounts_contacts. SQL

Shell> mysqldump -- User [username] -- Password = [Password] [database name] [Table name] \
>/Tmp/sugarcrm_accounts_contacts. SQL
Example:

View plaincopy to clipboardprint?

Shell> mysqldump -- User Root -- Password = myrootpassword db_test MERs \
> Db_test_customers. SQL

Shell> mysqldump -- User Root -- Password = myrootpassword db_test MERs \
> Db_test_customers. SQL
5. Restoring MySQL database.
The mysqldump utility is used only to take the MySQL dump. To restore the database from the dump file that you created in previous step, use MySQL command.

View plaincopy to clipboardprint?

Shell> MySQL -- U [username] -- Password = [Password] [database name] <[dump file]

Shell> MySQL -- U [username] -- Password = [Password] [database name] <[dump file]
Example:

View plaincopy to clipboardprint?

Shell> MySQL -- User Root -- Password = myrootpassword new_db <db_test. SQL

Shell> MySQL -- User Root -- Password = myrootpassword new_db <db_test. SQL
Do you know the other uses of mysqldump utility? Comment on this post.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.