Changing MySQL install directory

Comments None

Having already updated Apache and PHP I thought it was about time I updated MySQL now at version 5.7.

Downloaded, installed and tested successfully.

The only problem, for me at least, is that there is no option in the installation process to change the program and data directories. I need them to be in a subdirectory named Webserver on the D: Drive. So, after a bit of trial and error, I came up with this solution.

Open a command prompt as administrator.
Stop the Mysql service with net stop mysql57
Remove the service with sc delete mysql57

Now it is time to move the directories from their default location. I also move the my.ini file from the data directory to the server directory – its natural home.

Next it’s time to edit the my.ini file
uncomment and change basedir path
change datadir path
change secure-file-priv path

With that done open a command prompt as administrator in the MySQL bin directory as MySQL now can be re-instated as a service using mysqld.
e.g. mysqld —install MySQL57 —defaults-file=“D:\Webserver\MySQL\my.ini”

Service successfully installed.



There are currently no comments on this article.

Add a comment

Enter your comment below. Fields marked * are required. You must preview your comment before submitting it.

← Older Newer →