Search code examples
windowsmariadbwindows-server

Maria DB change datadir on windows server


I installed MariaDB on my windows server and saw it defaults the datadir where the databases are stored to C:\Program Files\MariaDB 10.2\data

I wanted it moved the the E: disk that's dedicated to database stuff.

I thought copying the datadir and then modifying the my.ini in the C:\Program Files\MariaDB 10.2\data datadir would solve it, but when I tried to restart the service it wouldn't start. I also tried setting the folder permissions to network service but that didn't seem to help.

What do I have to do to move my datadir on windows?


Solution

  • After a lot of searching I stumbled across http://baazgusht.blogspot.nl/2017/02/change-datadir-of-mariadb-in-window.html

    It gave me the hint I needed to move the datadir on windows.

    • open cmd in administrator mode(start search cmd, rightlick execute as administrator)
    • type Net stop MariaDB (or whatever you named your service. for me it was net stop "MariaDB 10_2_7"
    • CD to C:\program files\mariadb 10.2\(or wherever your mariadb is installed)
    • Type: xcopy data E:\MariaDB /O /X /E /H /K (E:\MariaDb is my location, you may have another location. replace E:\MariaDB with whatever you want, just use the same value below for the datadir in my.ini)
    • Xcopy will ask when the destination doesn't exist if it should be a file or a folder. Choose the option that represents Folder.
    • Type: notepad data/my.ini
    • change the value of datadir=C:\Pro.... to datadir=E:\MariaDB
    • save (ctrl + s)
    • in CMD type net start mariadb (or whatever you named your service. for me it was net start "MariaDB 10_2_7"