Heim  >  Artikel  >  Datenbank  >  mysqlhotcopy正则使用小技巧_MySQL

mysqlhotcopy正则使用小技巧_MySQL

WBOY
WBOYOriginal
2016-06-01 13:51:59638Durchsuche

mysqlhotcopy 是MySQL的热备工具,详细请看手册 ,为了安全起见我们给热备分配个用户:

grant select, reload, lock tables on *.* to 'hotcopy'@'localhost' identified by '123456';

      如果我们只想热备其中的一部分数据就有可能用到正则了,使用 mysqlhotcopy --help可以看到它支持的选项,其中有:--regexp 这个正则是和数据库名匹配的,比如:备份以abc开头的库,可以使用:

mysqlhotcopy --flushlog -u='hotcopy' -p='123456' --regexp= ^abc  /home/bak

备份以[a-d]开头的库,可以使用:

mysqlhotcopy --flushlog -u='hotcopy' -p='123456' --regexp=^[a-d] /home/bak

如果想备份某个数据库中的某些表的话,有可能要用到以下方法:

备份test库以abc开头的表:

mysqlhotcopy --flushlog -u='hotcopy' -p='123456' test./^abc/ /home/bak

备份test库除abc开头的表:

mysqlhotcopy --flushlog -u='hotcopy' -p='123456' test./~^abc/ /home/bak

备份test库以abc_a,abc_b,abc_c,abc_d,abc_e,......,abc_w开头的表:

mysqlhotcopy --flushlog -u='hotcopy' -p='123456' test./^/(abc_[a-w]/)/ /home/bak

Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn