Recently, I was working on one of the support ticket where customer was complaining that when he change datadir location by copying datadir from C: to F:, set mysql permissions and changing location in my.ini, he could not able to start mysql. Even no error msg in MySQL error log OR application log that why it doesn’t start.
We have checked all the required steps mentioned in documentations and blog posts but still the issue was not getting resolved. Finally, one of my colleague suggested to read this forum post.
and we found out that NETWORK SERVICE permission is required for datadir. By default, it will be given to the C:\ but not for other drives. So when we change any datadir to other drive like E:\ or F:\, we have to make sure that it does have NETWORK SERVICE permission. You can give it by following below steps.
- Right click on that particular dir or drive.
- Go to Properties -> Security – Advanced and check if there is NETWORK SERVICE principal available.
- If it’s not then press [ADD] button, then select a principal link and entered the object name NETWORK SERVICE, select it and press [OK]
- After that select NETWORK SERVICE, click on [EDIT] and checked Full control and press [OK]
- Now try to start MySQL and it will work.
I’m not sure why we need to give NETWORK SERVICE permission in Windows to the each disk drive or folder to be accessed but that is how it works.
EDIT: Just got update from Vladislav Vaintroub that mysqld runs as NETWORK SERVICE in Windows and so it requires that permission. Also, if we want to retain permission while copy dir/folder to different drive, we can use xcopy command for the same.