Stop the existing MySQL instance using services.msc, shutdown must be clean so that the instance flushes any pending changes to disk.
After successful instance shutdown, copy the data directory from existing location to the new location, in my case:
Existing location: C:\ProgramData\MySQL\MySQL Server 5.7
New Location: E:\MySQL
Change datadir parameter in current my.ini file. I have commented old entry and added new one:
# Path to the database root #datadir=C:/ProgramData/MySQL/MySQL Server 5.7\Data datadir=E:\MySQL\Data
Start MySQL instance using services.msc
After starting MySQL successfully, you can verify above changes by creating demo database and verify data dirctory for the same database. Test database: Myslott
Database Created successfully and myslott directory also created under new data directory.
Stay Tune. 🙂