mysql data migration, backup, restore

In fact, hot backup and restore, there are client operation tools, but here is the command line (under window, linux is not tested):

1. Backup and restore tables: (test is the database name)

备份:C:\Users>mysqldump test cloth -uroot -p123 > D:test.sql

Recovery: C:\Users>mysql test -uroot -p123 < D:test.sql

So if you have a table data error and need to be restored online, you can first create a new table to import the backup data, and then hot update to the original table.

2. Backup the database:

Backup: C:\Users>mysqldump test -uroot -p123 > D:test.sql

Recovery (same): C:\Users>mysql test -uroot -p123 < D:test.sql

 

The specific parameters can be viewed through C:\Users>mysqldump --help, which has a detailed introduction. The most used ones are -h (host address such as ip), -a (backup all databases)

 

 

Data migration: (data comma separated)

1、导入:load data infile '/t.txt' into table t FIELDS TERMINATED BY ',';

2、导出:select * from t into outfile '/t_0.txt';

data backup:

1. Hot standby ( described above )

2. For cold backup, copy the data directory.

reduction:

1. According to hot backup, hot restore

2. Restore from cold backup

3. Restore to the specified time point according to the binlog.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326546316&siteId=291194637