Home > Database > Mysql Tutorial > body text

mysqlhotcopy 正则使用小技巧

WBOY
Release: 2016-06-07 18:05:15
Original
884 people have browsed it

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

是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
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template