数据库复制 - mysql 直接拷贝data 目录下文件 进行数据库迁移时遇到的一些问题??
ringa_lee
ringa_lee 2017-04-17 15:28:02
0
3
679

我目前有两个数据库:

  1. mysql5.6.x

  2. mysql5.7.x

现在要将mysql5.6.x 的所有数据 迁移到 mysql5.7.x 中,采取的是直接将 mysqldata 目录下的相关文件夹(数据库)拷贝到 mysql5.7.x 的data目录下。

期间出现问题,通过百度知道: innodb 的表,直接复制文件是无法使用的,会提示 table doesn't exists ,在复制的时候,应将data目录下的 ibdata1 文件一并复制过去,并且删除ib_logfile1 ib_logfile1 文件。

如果是导入到全新的数据库中(mysql5.7.x 数据库新创建,里面没有任何已创建的数据库),那肯定是完美的做法。

可若是,将被导入的数据库中已经有创建的数据库了该怎么办??

若是将 mysql5.6.x 中的 ibdata1 文件 覆盖 mysql5.7.x 中的 ibdata1 , 则从mysql5.6.x 迁移过来的数据库全部有用 , 可 mysql5.7.x 中原先已创建的数据库将全被报废。

有没有办法实现: 通过直接拷贝文件的方式 迁移数据库, 且不会出现 上述问题??

希望大神们都分享些: 数据库迁移的方法

ringa_lee
ringa_lee

ringa_lee

reply all(3)
大家讲道理

You can use navicat's data transfer to transfer only the data you need to migrate (tables, views, functions, etc.).

小葫芦

xtrabackup

左手右手慢动作

1. There is an official upgrade manual, why do you need to read Baidu...
http://dev.mysql.com/doc/refm...

2. If the destination machine already has a database, you still need to upload the entire database directory. What do you think?

Migrating the database by directly copying files is inherently risky, and you will continue to make it more difficult for yourself.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template