[英]How do I move a MySQL database from one hard drive to another?
I am using MySQL 5.5 and MySQLWorkbench on Windows7.我在 Windows7 上使用 MySQL 5.5 和 MySQLWorkbench。 I have successfully created a database on my C: drive but I want to move it to my E: drive.
我已经在我的 C: 驱动器上成功创建了一个数据库,但我想将它移动到我的 E: 驱动器。 I stopped the mysqld daemon and edited the my.ini file to change datadir="C:/ProgramData/MySQL/MySQL Server 5.5/Data/" to datadir="E:/MySQL/data/".
我停止了 mysqld 守护进程并编辑了 my.ini 文件,将 datadir="C:/ProgramData/MySQL/MySQL Server 5.5/Data/" 更改为 datadir="E:/MySQL/data/"。 I copied the data from the C: location to the E: location.
我将数据从 C: 位置复制到 E: 位置。 I can start the mysqld process, but the database I created does not appear.
我可以启动mysqld进程,但是我创建的数据库没有出现。 Would anyone have any explanation as to what I am doing wrong?
有人会对我做错什么有任何解释吗?
As I wanted my innodb database to sit on another partition, I stopped MySQL from the MySQL Workbench.因为我希望我的 innodb 数据库位于另一个分区上,所以我从 MySQL Workbench 中停止了 MySQL。 I copied my innodb database ibdata1 as well as 2 log files which MySQL automatically created in my C:\\ProgramData\\MySQL\\ folder to a new folder on my E: partition.
我将我的 innodb 数据库 ibdata1 以及 MySQL 在我的 C:\\ProgramData\\MySQL\\ 文件夹中自动创建的 2 个日志文件复制到我的 E: 分区上的一个新文件夹中。 I added the following to my.ini:
我在 my.ini 中添加了以下内容:
innodb_data_home_dir = "E:/MySQL Data"
Now, when I start my database, all changes are made to the ibdata1 in the E: drive.现在,当我启动我的数据库时,所有更改都会对 E: 驱动器中的 ibdata1 进行。
Basicly you would like to copy all the contents in the old directory to the new directory.基本上,您希望将旧目录中的所有内容复制到新目录中。 Make sure that while doing this you don't also copy binlogs (if any, they look like mysql-bin.001 etc. and also don't copy mysql-bin.index because that contains real path reference to the old binary logs).
确保在执行此操作时您不会同时复制二进制日志(如果有,它们看起来像 mysql-bin.001 等,也不要复制 mysql-bin.index 因为它包含对旧二进制日志的真实路径引用) . Once you do that, you should be able to restart the mysql daemon and login to see the databases.
完成此操作后,您应该能够重新启动 mysql 守护程序并登录以查看数据库。
PS: not tested, but should work. PS:未测试,但应该可以工作。
When I was trying to move my database I ran into the issue where windows didn't have the same permissions on the new data folder as the original.当我试图移动我的数据库时,我遇到了一个问题,即 windows 对新数据文件夹的权限与原始文件夹不同。 You may check that the correct user(s) have access to the new folder by going to the properties of the folder then selecting the security tab.
您可以通过转到文件夹的属性然后选择安全选项卡来检查正确的用户是否有权访问新文件夹。
使用此工具将数据库转储到磁盘http://sourceforge.net/projects/mysqlbutool/然后使用此工具将其恢复到新服务器http://www.webyog.com/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.