Tips for using mysqlhotcopy regular expressions mysqlhotcopy is a MySQL hot standby tool. for details, please refer to the manual. for security reasons, we will assign users to hot standby:
Grant select, reload, lock tables on *. * to 'hotcopy' @ 'localhost' identified by '123 ';
If we only want to hot-standby some of the data, we may use regular expressions. use mysqlhotcopy -- help to see the supported options, including: -- regexp: this regular expression matches the database name. for example, to back up a database starting with abc, you can use:
Mysqlhotcopy -- flushlog-u = 'hotcopy'-p = '000000' -- regexp = ^ abc/home/bak
To back up a database starting with [a-d], you can use:
Mysqlhotcopy -- flushlog-u = 'hotcopy'-p = '000000' -- regexp = ^ [a-d]/home/bak
To back up some tables in a database, you may need to use the following methods:
Back up tables starting with abc in the test database:
Mysqlhotcopy -- flushlog-u = 'hotcopy'-p = '000000' test./^ abc // home/bak
Back up tables starting with abc in the test database:
Mysqlhotcopy -- flushlog-u = 'hotcopy'-p = '000000' test ./~ ^ Abc // home/bak
Back up tables starting with abc_a, abc_ B, abc_c, abc_d, abc_e,... and abc_w in the test database:
Mysqlhotcopy -- flushlog-u = 'hotcopy'-p = '000000' test./^/(abc _ [a-w]/) // home/bak