For Windows, as of the MySQL Installer 1.4.6 (2015-04-07), the data location may be specified in a registry key that specifies the location of the my.ini
file, so if the data was initially installed in a non-default location the my.ini
file won't be in C:\ProgramData\MySQL\MySQL Server x.x\
.
The location of the registry values are (at least as of MySQL 5.6):
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\MySQL AB\MySQL Server x.x\
Location
is a REG_SZ
that points to the folder where the MySQL application files are located; by default: C:\Program Files\MySQL\MySQL Server x.x\
DataLocation
is a REG_SZ
that points to the folder where my.ini
is located; by default also: C:\Program Files\MySQL\MySQL Server x.x\
Also, the my.ini
file path is included in the service command under this registry key:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\MySQLXX
in the ImagePath
REG_EXPAND_SZ
value.
The default value of this string is: "C:/Program Files/MySQL/MySQL Server 5.6/bin\mysqld" --defaults-file="C:\Program Files\MySQL\MySQL Server x.x\my.ini" MySQLXX
So the bottom line is that in order to move data files in this scenario you have to follow the steps posted by @ITCuties with some additions.
Here are the full steps:
- Shutdown mysql.
- Look up the above
DataLocation
registry value to find the current my.ini
file location, and if you are wanting to also move the my.ini
file update the DataLocation
path and move the my.ini
file to this new path.
- If you are changing the location of the
my.ini
file, you need to update the path in the service command registry key listed above.
- Open the
my.ini
file, locate the datadir
parameter. Move the files from this datadir
path to the path in which you want the data to reside, and then also update the datadir
parameter with this new path.
- Start mysql.