Okay, moving the C:\Windows\ServiceProfiles\MariaDB folder to another drive is a good idea if it's taking up too much space on your C: drive. However, you cannot simply cut and paste this folder directly because it's tied to a Windows service account and contains potentially active files.
The primary reason this folder grows large is usually due to temporary files created by MariaDB. The setting that controls where MariaDB stores these temporary files is the tmpdir variable in your MariaDB configuration file (my.ini).
Here's the safest and most effective way to "move" it, which really means telling MariaDB to use a different location for its temporary files, and then safely clearing out the old ones.
Important Pre-requisites & Warnings:
- STOP MariaDB Service: You MUST stop the MariaDB service before making any changes or attempting to clear files. Running MariaDB will have files locked, and attempting to move or delete them while it's running can corrupt your database.
- Backup: While this process usually doesn't affect your actual database files (which are in the main data directory), it's always a good practice to have a recent backup of your MariaDB databases before making any configuration changes.
- Administrator Privileges: You'll need Administrator privileges on your Windows machine to stop/start services and edit system files.
Steps to Move the MariaDB Temporary Directory (tmpdir):
Step 1: Create the New Temporary Directory
- Choose a new drive and path where you want MariaDB to store its temporary files. For example, let's say
D:\MariaDB_Temp.
- Create this folder:
D:\MariaDB_Temp.
Step 2: Stop the MariaDB Service
- Open the Services Manager in Windows:
- Press
Win + R, type services.msc, and press Enter.
- Alternatively, search for "Services" in the Start Menu.
- Locate your MariaDB service. It might be named something like
MariaDB, MySQL, MariaDB XX (where XX is the version), or something specific you named during installation.
- Right-click on the MariaDB service and select Stop.
- Wait for the service status to show "Stopped".
Step 3: Edit the MariaDB Configuration File (my.ini)
Locate your MariaDB configuration file, my.ini. This file is typically found in one of these locations:
C:\Program Files\MariaDB\MariaDB Server [version]\data\my.ini (less common for the main config, but sometimes)
C:\Program Files\MariaDB\MariaDB Server [version]\my.ini
C:\ProgramData\MySQL\MySQL Server [version]\my.ini (for older MySQL, but MariaDB can use ProgramData too)
- If you can't find it, search your C: drive for
my.ini.
Open my.ini with a plain text editor (like Notepad) as an Administrator. Right-click Notepad, select "Run as administrator," then open the my.ini file from within Notepad.
Find the [mysqld] section.
Add or modify the tmpdir line within the [mysqld] section to point to your new temporary directory.
- If
tmpdir already exists, change its path.
- If
tmpdir does not exist, add it.
It should look something like this:
[mysqld]
# ... other settings ...
tmpdir="D:/MariaDB_Temp"
# ... other settings ...
Note the forward slashes / are generally preferred in my.ini paths, although backslashes \ often work too.
Save the my.ini file.
Step 4: Set Permissions for the New Directory (Crucial!)
The MariaDB service account needs full read/write access to the new D:\MariaDB_Temp folder.
- Right-click on the
D:\MariaDB_Temp folder you created.
- Select
Properties.
- Go to the
Security tab.
- Click
Edit...
- Click
Add...
- In the "Enter the object names to select" box, type the name of the MariaDB service account. This is the tricky part:
- Go back to Services Manager (
services.msc).
- Right-click your MariaDB service and select
Properties.
- Go to the
Log On tab.
- Note the account listed there. It's often
NT SERVICE\MariaDB (where MariaDB is your service name), NETWORK SERVICE, LOCAL SYSTEM, or a custom user like MariaDBUser.
- Enter that exact account name into the "Enter the object names to select" box (e.g.,
NT SERVICE\MariaDB).
- Click
Check Names. It should underline the name if found correctly.
- Click
OK.
- Select the newly added MariaDB service account in the "Group or user names" list.
- In the "Permissions for..." box, check the
Full control checkbox under "Allow".
- Click
Apply and then OK on all windows.
Step 5: Start the MariaDB Service
- Go back to the Services Manager (
services.msc).
- Right-click on your MariaDB service and select Start.
- Monitor the status. If it starts successfully, that's a good sign. If it fails, check the Windows Event Viewer for errors (under "Windows Logs" -> "Application" and "System") - these will provide clues.
Step 6: Clean Up the Old Temporary Files
Once MariaDB is running successfully with the new tmpdir location, you can safely clean up the old temporary files.
- Navigate to
C:\Windows\ServiceProfiles\MariaDB\AppData\Local\Temp.
- Select all files and folders within this
Temp directory (do NOT delete the Temp folder itself, or the MariaDB folder, or AppData\Local etc.).
- Delete them. These are the temporary files that were taking up space.
Troubleshooting if MariaDB Fails to Start:
- Check
my.ini syntax: Even a typo can prevent it from starting.
- Check Event Viewer: This is your best friend for service startup issues.
- Permissions: Incorrect permissions on the new
tmpdir are a very common cause of failure. Double-check them carefully.
- Service Account Name: Ensure you entered the correct service account name when setting permissions.
By following these steps, MariaDB will start using the new D:\MariaDB_Temp location for its temporary files, preventing future bloat on your C: drive.