简体   繁体   English

如何将 MySQL 数据库从一个硬盘驱动器移动到另一个硬盘驱动器?

[英]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.

相关问题 如何在MySQL中将数据从一个表移到另一个表? - How do I move data from one table into another in MySQL? 如何将MYSQL 5.0数据库从一台服务器移动到另一台服务器 - How to move MYSQL 5.0 Database from one server to another 如何使用PHP将一组特定的用户数据从一个MySQL数据库移动到另一个数据库? - How can I move a specific set of user data from one MySQL database to another with PHP? 如何将MySQL数据库移至外部硬盘? - How to move a MySQL database to an external hard disk? 如何从存储在备份硬盘驱动器上的Windows 7 MySQL数据库中获取数据库? - How can I get a database out of a Windows 7 MySQL Database stored on a backup hard drive? 如何使用另一个数据库中的数据更新 MySQL 数据库? - How do I update a MySQL database with the data from another database? 如何将大型MySQL数据库从一台服务器重定位到另一台服务器? - How do I relocate a big MySQL database from one server to another? Mysql过程定期将数据从一个数据库移动到另一个数据库 - Mysql procedure to move data from one database to another perodically 在 MySQL 数据库中查找数据并将数据从一列移动到另一列 - Find and Move Data From One Column To Another in MySQL Database 在mysql和Codeigniter中将值从一个数据库移动到另一个数据库 - Move values from one database to another in mysql and Codeigniter
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM