MySQL Service on Windows Won’t Start After Changing datadir

MySQLwindowswindows-server

Tried to change the data directory for a default Windows installation of MySQL. Here's the steps I've taken.

  • Stopped the MySql service.
  • Located the data directory of MySql and moved it to another drive, ensuring the path name had no spaces.
  • Made a copy of the my-default.ini file in C:\Program Files\MySQL\MySQL Server 5.7 then renamed it to my.ini and edited it to look like this:

[mysqld]
datadir = F:\ProgramData\MySQL\MySQLServer\Data

  • Copied the contents of the original data folder into this new data folder.
  • The MySql Service is running under the NETWORK SERVICE user, so I have given this user full control permission on the new folder.
  • Deleted the original data folder.
  • MySql Service fails to start, with no useful error messages appearing in the windows event logs.

As far as I know, the MySql error logs are located in the datadir, so it's not much help looking there?

How can I find and fix what I've done wrong?

Best Answer

If You open Windows Services and check the service properties, You will find something like this:

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

not enough to change datadir in my.ini file, need also point windows to run service with proper my.ini file