Bug #89991 Can't Move Data Directory
Submitted: 9 Mar 2018 14:31 Modified: 16 Mar 2018 10:31
Reporter: Colin Bruce Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:5.7 OS:Windows (8.1)
Assigned to: MySQL Verification Team CPU Architecture:Any (X64)

[9 Mar 2018 14:31] Colin Bruce
Description:
The installer forces the data directory to be installed in C:\Programdata. This is not ideal since usually (and certainly in my case) the C drive is not very big. Without that option, the alternative is to move the folder after installation. This does not work. The process should be straight forward and is documented however it fails and after the move the MySQL server will not start.
I used xcopy to copy the data as follows:

xcopy Data E:\DATABASES\MySQL /O /X /E /H /K

and I updated the my.ini file with the path shown in that command. I left the file in its original location so there should be no need to update the service or the registry. It failed to start. I then changed the security settings of the parent folder and its subfolders so that "Everyone" had "Full Control" and it still failed to start which, I think rules out permissions. Finally, I deleted all file files with names beginning with "ib" and the server started. However, when I stopped the server and tried to start it again it failed to start. I can repeat this as often as required. However, deleting the IB files is not really a solution I suspect.

How to repeat:
Install MySQL 5.7 on Windows 8.1 (or possibly other versions as well)
Check that the server starts.
stop the server
copy or move the data directory
update the my.ini file
try to start and it will fail.
Delete the file "ib*" from the data folder
Try to start and it will succeed
Stop the server and start it again
It will fail to start

Suggested fix:
Make it easier to move the data directory.
[9 Mar 2018 14:34] Colin Bruce
Error file

Attachment: HOME-PC.err (application/octet-stream, text), 2.40 KiB.

[9 Mar 2018 14:36] Colin Bruce
I've attached the error file and I suspect it makes clear what the problem is. The error file is in the new location so MySQL is able to write to the directory and if I delete the ib* files it recreates them so why it then complains: "os_file_get_status() failed on '.\ibdata1'. Can't determine file permissions" when it created the file just a few minutes before is beyond me.
[9 Mar 2018 14:54] Colin Bruce
Now it gets stranger. I moved the data directory from where it was on the E drive to a new location on the D drive, updated the my.ini file and the server started perfectly. Right I thought it must be permissions but starting at the drive and working down both drives and sub folders looked pretty much the same. Anyway, I then moved the data folder back to the E drive and the server started without a problem. So now I have no idea what the cause is. I had moved it to the E drive many many times with no success. The only difference this time is that I didn't use xcopy but just did a cut and paste with Windows Explorer. However, the security settings seem to be just the same unless there is something hidden the Windows Explorer doesn't show.
[16 Mar 2018 10:31] MySQL Verification Team
Hi,

This is not a bug, it has to do with permissions of the target directory.

Check permissions with showacls.exe (should be in resource kit description how to use it should be here https://docs.microsoft.com/en-us/previous-versions/windows/it-pro/windows-server-2003/cc78...) ) or you can use icacls that should be there already.

If you need help setting up our Support & Consulting team is always there to help, or you can also ask for help on https://forums.mysql.com/ 

thanks
Bogdan