如何在 Windows 上更改 MySQL 数据目录?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/26648045/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to change MySQL data directory on windows?
提问by Erick Leddel
I went to this location C:\ProgramData\MySQL\MySQL Server 5.6 to find my.ini, then I modified the datadir to: datadir=C:/ProgramData/MySQL/MySQL Server 5.6/Dataz
我去C:\ProgramData\MySQL\MySQL Server 5.6这个位置找到my.ini,然后我把datadir修改为:datadir=C:/ProgramData/MySQL/MySQL Server 5.6/Dataz
I only added the letter z to the original path, then I created the dataz folder in the MySQL Server 5.6 directory.
我只在原始路径中添加了字母z,然后在MySQL Server 5.6 目录中创建了dataz 文件夹。
then i closed and opened mysql to restart it
然后我关闭并打开 mysql 重新启动它
I haven't been able to make it work. What am i missing?
我一直无法让它发挥作用。我错过了什么?
2 hours later...
2小时后...
I wasn't restarting mysql server properly, I was only clicking the mysql command client close button. someone told that I had to restart the computer for the changes to take effect, if didn't know how to restart mysql server properly.
我没有正确重启 mysql 服务器,我只是点击了 mysql 命令客户端关闭按钮。有人告诉我必须重新启动计算机才能使更改生效,如果不知道如何正确重新启动 mysql 服务器。
After doing this the dataz folder had new files. this is new because I wasn't be able to create this files before They appeared after I restart the computer.
执行此操作后,dataz 文件夹中有新文件。这是新的,因为在我重新启动计算机后它们出现之前我无法创建这些文件。
Now, MySQL command client shows an error and closes itself after I enter my password. I can't see the error because the error is shown for one second or less
现在,MySQL 命令客户端显示错误并在我输入密码后自行关闭。我看不到错误,因为错误显示一秒钟或更短时间
回答by Gianluca Colombo
If you change the data directory, you have to copy or move all the data inside, to the new directory! The database file includes also all the mysql configuration so, the reason why your MySql doesn't start is because It doesn't find the MySql configuration schema..
如果更改数据目录,则必须将里面的所有数据复制或移动到新目录中!数据库文件还包括所有的mysql配置,所以你的MySql没有启动的原因是因为它没有找到MySql配置模式..
Hope my English is clear
希望我的英语很清楚
回答by Kevin
You may need to check the login accont of the service MySQL57, if the account is Network Service, you may need to add this account security permission to the parent folder of the new mysql data folder
可能需要查看服务MySQL57的登录账号,如果账号是Network Service,可能需要将此账号安全权限添加到新建mysql数据文件夹的父文件夹中
回答by Darkhan ZD
In my case, I've given the folder permission to read, modify for Users account. Then it worked.
就我而言,我已授予文件夹读取、修改用户帐户的权限。然后它起作用了。