当前windows下最新版的mysql (5.6.22.0)在安装时没有指定安装路径和数据存放路径的选项,而是默认把程序安装在C盘Program Files下,数据也存放在C:/ProgramData下面,找到my.ini,修改datadir变量后重启服务会报1067错误。解决办法如下:
来自:http://bugs.mysql.com/bug.php?id=68584
我用中文大概总结一下:
原因:安装MySQL后在创建MySQL服务时使用的是NETWORK SERVICE的用户,当你改变datadir之后,新的路径NETWORK SERVICE没有读写权限。
解决办法:给MySQL服务的登录账户赋予可读写权限。具体操作如下:
1、在服务那里右击MySQL服务名>属性>登录>查看创建服务的账户名,一般是NETWORK SERVICE。
2、给datadir指定的目录添加NETWORK SERVICE具有所有权限。
[13 Mar 2013 7:59] david trillo
I write on the right my.ini file.
The service is created like this:
"C:\Archivos de programa\MySQL\MySQL Server 5.6\bin\mysqld" --defaults-file="C:\Documents and Settings\All Users\Datos de programa\MySQL\MySQL Server 5.6\my.ini" MySQL56
And THIS is the file iI'm changing!
Finally, i got WHY was this error happening!
When creating the service, It used a user like NTblablabla, instead of a local user.
After changing this, everything was OK!
i'm happy to find the solution. It wasn't the datadir, but how the service was created (the user)!
i hope this can be useful to other users!
[13 Mar 2013 21:28] Wichen Moormann
Thanks to david trillo. We solved the problem also.
It was not a matter of correct my.ini.
It was a matter of user rights of service and data dir.
Let me describe it for Windows Server 2008 R2, which was the last OS i used.
I am always logged in as administrator, but that is not the point.
Important is:
The installer installs the service by default for the user: "network service"
(see properties of the service MySQ56).
If we copy the data dir to a new location (e.g. C: to D:) it has by default
the security rights of the user: "local system"
(see properties of the the new data dir).
---------------------------------------------------------
These different user/rights are the reason for 1067 here.
---------------------------------------------------------
Now we have at least 2 choices:
1. change the service user to: "local system" (as david trillo did)
or
2. add to the data dir security properties the user: "network service",
with all rights.
Both solution work OK when the service is started!
On other OS the problem should be solved analogous.
I hope this is helpfull for others.
Thanks to david trillo again.