Why MySQL doesn’t start after changing datadir in Windows 10

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.

https://forums.mysql.com/read.php?169,659235,659254#msg-659254

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.

  1. Right click on that particular dir or drive.
  2. Go to Properties -> Security – Advanced and check if there is NETWORK SERVICE principal available.
  3. 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] 
  4. After that select NETWORK SERVICE, click on [EDIT] and checked Full control and press [OK] 
  5. 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.

https://support.microsoft.com/en-us/help/323007/how-to-copy-a-folder-to-another-folder-and-retain-its-permissions

2 thoughts on “Why MySQL doesn’t start after changing datadir in Windows 10

  1. Its helpful but just one question, as mentioned above that data dir has been changed and network permissions sets for new location. So in that case do we need to change the network permissions(revoke) of previous loction also ?

  2. Hi,
    Thanks for the question. The answer is, it depends. Because most of the time when people change datadir, they will not keep the copy behind due to many reasons like security OR no enough diskspace to keep two copy of dbs etc. So, if you are removing the old datadir then no need to revoke permission otherwise, you can keep it as it is OR revoke. Its on you.

Leave a Reply to admin Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.