Home > Database > Mysql Tutorial > MySQL同主机不同数据库的复制命令

MySQL同主机不同数据库的复制命令

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-07 15:46:40
Original
1042 people have browsed it

MySQL同主机不同数据库的复制命令:注意运行在Terminal中,不运行在MySQL命令行中。 1 mysqldump Portal_DEV - u root - ppassword1$ -- add - drop - table | mysql Portal_Optimize - u root - ppassword1$ 在复制过程中,出现如下报错: 1 ERROR 1153 ( 0

MySQL同主机不同数据库的复制命令:注意运行在Terminal中,不运行在MySQL命令行中。

<span>1</span><span> mysqldump </span><span>Portal_DEV</span><span>-</span><span>u root </span><span>-</span><span>ppassword1$ </span><span>--</span><span>add</span><span>-</span><span>drop</span><span>-</span><span>table </span><span>|</span><span> mysql </span><span>Portal_Optimize</span><span>-</span><span>u root </span><span>-</span><span>ppassword1$</span>
Copy after login

在复制过程中,出现如下报错:

<span>1</span><span> ERROR </span><span>1153</span><span>(</span><span>08S01</span><span>)</span><span> at line </span><span>1160</span><span>:</span><span>Got</span><span> a packet bigger than </span><span>'</span><span>max_allowed_packet</span><span>'</span><span> bytes</span>
<span>2</span><span> mysqldump</span><span>:</span><span>Got</span><span> errno </span><span>32</span><span>on</span><span> write</span>
Copy after login

需要将my.cnf中的max_allowed_packet 放大,我本机默认是1M,放大至32M。重启MySQL。

OK. 以上方案适用于小数据量的数据库。下面来个大容量(1G以上)的。

<span>1</span><span>  mysqldump </span><span>-</span><span>uroot </span><span>-</span><span>ppassword </span><span>--</span><span>quick </span><span>Portal_DEV</span><span>|</span><span> gzip </span><span>></span><span>Portal_DEV</span><span>.</span><span>contents</span><span>.</span><span>gz</span>
Copy after login

通过以上命令,将Portal_DEV数据库导成Portal_DEV.contents.gz压缩文件。

<span>gunzip </span><span><span>Portal_DEV</span><span>.</span><span>contents</span><span>.</span><span>gz </span><span>|</span><span> mysql </span><span>-</span><span>uroot </span><span>-</span><span>ppassword </span><span>Portal_Optimize</span></span>
Copy after login

然后通过以上命令,将Portal_DEV导入Portal_Optimize数据库。

Perfect, it's done!!!

来自:http://www.cnblogs.com/droko/archive/2011/10/25/2224130.html

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
Latest Issues
MySQL stops process
From 1970-01-01 08:00:00
0
0
0
Error when installing mysql on linux
From 1970-01-01 08:00:00
0
0
0
phpstudy cannot start mysql?
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template