First stop the MySQL service.
Two. Change the database storage master path in MySQL configuration file My.ini
Open the My.ini file in the folder C:\ProgramData\MySQL\MySQL Server 5.7,
Locate datadir= "C:/programdata/mysql/mysql Server 5.7/data", which is the default database storage master path setting.
Now change it to D:/program files/data (note the backslash "/")
Click "File" on the menu bar and click "Save" when you are done.
Three. Copy the database files and folders from the old database storage master path to the new storage master path
Copy all the files and folders in the C:/programdata/mysql/mysql Server 5.7/data folder to your new folder directory.
Four. Restart the MySQL service
Five. Verify that the operation to change the database storage master path is successful
Show global variables like "%datadir%";
Modify the database storage master path in MySQL