Need: To store / accesses dbTable data from a separate drive not the default

I was using MySQL 5.7 so far & as specified in the solution - Link1 I added the my.ini file with the info as stated & it worked fine.

I now uninstalled MySQL 5.7, installed MySQL 8, created a my.ini file & specified the info as stated in this solution Link2. But when I check it still points to the default C:\ drive & hence unable to access data from the existing database stored in E:\ drive



C:\ProgramData\MySQL\MySQL Server 8.0\Data\

The new my.ini file which I have created as below in

C:\Program Files\MySQL\MySQL Server 8.0 

datadir = E:/MySqlData

Hope the issue faced is clear, await inputs.


I found this input - Link Could anyone let me know if this could be a reason ? Also any known hex editors for Windows 10 ?

Update: Even after removing the hex characters, the server still does not start if I point the parameter datadir in my.ini file to my database folder in another drive

4 Answers 4


Make sure the directory where you want to write the data files is accessable for MySQL. I put it the security settings on Everyone.

You might need to copy the data also from old data directory to the new one.


Assuming you specified my.ini location when you created the service, then you can open services, right click MySQL service, and choose properties. open my.ini file and check datadir location.

installed MySQL without specify my.ini location, navigate to mysql\bin directory using PowerShell or CMD. then execute the following command

.\mysqld --help --verbose > \output\location\out.txt
 notepad \output\location\out.txt

then search for Default options are read from the following files in the given order: this should specify my.ini location. and locate it from their.

and change datadir based inside the used my.ini

  • Thanks,what baffles me is that after specifying the file path in my.ini in C:\Program Files\MySQL\MySQL Server 8.0\my.ini to point to E:\ drive & also updating the Windows Redistry, the server does not start. This behavior I notice in Ver 8, while it was working fine while using Ver 5.7. Anything else I need to check ?
    – iCoder
    Jul 3, 2019 at 5:26
  • would you please provide me with changes you did to registry? and the error you got when you try to start the SID using CL Jul 3, 2019 at 5:55
  • The changes done to registry as per the solution provided (Step-3) in Link 2 cited in my query above. When I open Services.msc, right click on MySQL80 & click start services it takes a long time & at the end says cannot start. But if the 'datadir' points to the default drive, then the server starts immediately.
    – iCoder
    Jul 3, 2019 at 7:43
  • stop your SID service then open powershell, then execute the following command as administrator copy-item C:\ProgramData\MySQL\MySQL Server 8.0\Data\ E:\Data. after that open ini file and edit datadir to e:\Data then try to start the service. Jul 3, 2019 at 8:24

Try to save as your my.ini to ANSI. MySQL's default encoding of my.ini now is UTF-8. It should be ANSI, then restart the mysql server.


It may be tricky if some detail was ignored. The initialize step is really crucial when the Server has been initialized before. There are 4 steps.

1.Check the MySql80 service configuration.

Almost the time we will have a config, like this

"C:\Program Files\MySQL\MySQL Server 8.0\bin\mysqld.exe" --defaults-file="C:\ProgramData\MySQL\MySQL Server 8.0\my.ini" MySQL80

2.Change the datadir property in the my.ini file.

Maybe something like this datadir=E:\mysql\Data

3.Remove all files in the $datadir.

This is important and cannot be omitted. Or the initialize step will fail.

4.Reinitialize the MySQL80 service with the actual same options.

"C:\Program Files\MySQL\MySQL Server 8.0\bin\mysqld.exe" --defaults-file="C:\ProgramData\MySQL\MySQL Server 8.0\my.ini" --initialize --console

As you see, just remove the service name and append two options to the service starting command.

After initialization, the password for root will be printed on the console. Check this official document for more information;

  • I am having a related issue. I have turned the MySQL80 service off in the services program. I went and copied the database files located in C:/ProgramData/MySQL/MySQL Server 8.0/ to D:/MySQL, and then gone and restarted the server in services, but when I do that it tells me it started and then stopped immediately. I'm not sure what the issue is, I've quadruple checked all the paths - they are correct. And if I restore the path back to the C: location, the server starts fine. Are you saying I need to delete/move the files in the C: location?
    – Brad Davis
    Mar 29, 2022 at 16:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.