...
Locate your my.ini file
Example: C:\ProgramData\MySQL\MySQL Server 5.6
In the my.ini file find the datadir and then locate the current directory
Usually defaults to: C:/ProgramData/MySQL/MySQL Server 5.6/data
Create a new destination folder for the MySQL Data
If NOT using the XCopy variation which I recommend then you need to manually set some permissions
Verify permissions are the same on the old and the new directory
Be sure that NETWORK SERVICE has full permissions (the owner of the service as of MySQL 5.6)
Before V5.6 it was owned by SYSTEM which already had full permissions on ALL folders
Change the datadir value to the name of the new location
end the new location path with a slash /
This doesn’t seem to be needed in MySQL
Save the my.ini
DO NOT save your edits with NOTEPAD. It often corrupts the file though it might look okay. Using Notepad++ in Administrator mode is recommended.
Stop the MySQL service
Copy all the data files to the new location - use the xcopy command below is quite easy
include the ibdata* and ib_logfile* files (required for INNODB type tables)
Restart the MySQL service
...
The use of xcopy
allows the permissions to be copied as well.
Be sure to run the xcopy command in a cmd window using run as Administrator to avoid a permission denied error.
Code Block |
---|
xcopy "\C:\ProgramData\MySQL\MySQL Server 8.0\Data" "WD:\MySQL\Data" /E /H /K /O /X |
Why not simply copy? Well because that's not COOL!, this helps you not lose permissions on the copied folder, so that when you restart
MySQL80
, it won't give a stupid error: "The MySQL80 service on Local Computer started and then stopped. Some services stop automatically if they are not in use by other services or programs." - Courtesy:Microsoft
...