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