HiveBrain v1.2.0
Get Started
← Back to all entries
debugsqlMinor

MySql service on Windows won't start after changing datadir

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
afterdatadirmysqlservicewindowsstartwonchanging

Problem

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?

Solution

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

Code Snippets

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

Context

StackExchange Database Administrators Q#154141, answer score: 4

Revisions (0)

No revisions yet.