Home  >  Article  >  Database  >  关于MySQL数据迁移--data目录直接替换注意事项的详解_MySQL

关于MySQL数据迁移--data目录直接替换注意事项的详解_MySQL

WBOY
WBOYOriginal
2016-06-01 13:25:11768browse

bitsCN.com 近日更换服务器,要做数据库迁移,将数据库内的数据从服务器A迁移到服务器B。
由于数据量较大,直接做dump耗时太长,故而采用如下方式处理:
首先,在服务器B上安装了与服务器A同版本的MySQL,停止MySQL服务,将安装后的data目录删除;
然后,服务器A锁住全部表,从服务器A将整个data目录和数据文件直到拷贝到服务器B上,修改服务器B上MySQL的my.cnf文件中的datadir指向新的data目录。
最后,启动服务器B上的MySQL服务。
结果启动失败,报出 “无法启动MySQL服务”异常,查看错误日志,发现问题描述如下:
InnoDB: Error: log file ./ib_logfile0 is of different size 0 63963136 bytes
InnoDB: than specified in the .cnf file 0 6291456 bytes!
这段信息的意思是日志文件比my.cnf中设置的日志文件配额要大,服务不能启动。原因是日志文件从服务器A复制而来,在服务器A上的my.cnf中日志配额要比服务器B上的my.cnf日志配额大,
计算日志文件大小:63963136/(1024*1024)=61M,6291456/(1024*1024)=6M,怪不得呢?
将服务器B上的my.cnf中的innodb_log_file_size的参数设置为61M,再次启动mysql,启动成功。

总结需要注意事项:
1.修改datadir为新的data目录。
2.合理修改innodb_log_file_size的值为实际迁移过来的日志文件大小。
3.字符集/默认引擎的修改,要与迁移前统一。
bitsCN.com

Statement:
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