MySQL Learning (4)-mysqldump backing up and recovering data

Source: Internet
Author: User

Background

Recently in the company to do data migration work, using MySQL database in the test environment simulation data migration, in the process of migration testing need to do data backup and recovery

MySQL data backup and recovery is relatively simple, you can choose the Mysqldump tool, here is a simple mention of the migration of data in the process of some common operations

1. Back up and restore the entire database

Back up the database using the mysqldump command on the primary database:

Mysqldump-uroot-p jobs >/usr/local/mysql/jobs.sql

SSH Login to backup database:

(1). Upload the primary database snapshot Jobs.sql from the previous backup to a path from the database via FTP, SFTP, or by other means, such as I put in the/user/local/mysql directory;
(2). From the backup of the import main library:

-uroot-p-B Jobs </usr/local/mysql/jobs.sql

2. Backing up a table in a database

Back up a table in the database using the mysqldump command on the primary database:

Mysqldump-uroot-p jobs bus_agency >/usr/local/mysql/bus_agency.sql

(1). Upload the primary database snapshot Jobs.sql from the previous backup to a path from the database via FTP, SFTP, or by other means, such as I put in the/user/local/mysql directory;
(2). From the backup of the import main library:

#mysql-uroot-p Jobs </usr/local/mysql/bus_agency.sql

Note: The above commands are executed on Linux terminal, do not need to log in MySQL, and please speak MySQL installation directory export to environment variable

Such as:

mysql_home=/usr/local/Mysqlpath= $PATH: $MySQL _home/binexport PATH

Not to be continued

MySQL Learning (4)-mysqldump backing up and recovering data

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.