One of the more common tasks you will encounter in moving a system or user database from one physical location to another location. For example, Microsoft recommends that we place our backups, data files, transaction logs and tempdb files on four separate drives. However, the installer by default will place the system databases (Master, Model and MSDB) on the C drive. Even though the rest of the install will allow you to place them on other drives, to even include the tempdb. This will cause some performance issues for you if you leave them there. This article will walk you through the process of making those changes.
Here is the TechNet article that you can reference as you makes these changes: Move System Databases
Moving the master Database
To move the master database, please follow these steps.
- From the Start menu, point to All Programs, point to Microsoft SQL Server 2008R2, point to Configuration Tools, and then click SQL Server Configuration Manager.
- In the SQL Server Services node, right-click the instance of SQL Server (for example, SQL Server (MSSQLSERVER)) and choose Properties.
-
Click on the Log On Tab and stop the service for the SQL Service instance
Image may be NSFW.
Clik here to view.
-
Click on the Advanced Tab and then click the Startup Parameters field
Image may be NSFW.
Clik here to view.
-
In this example, I am moving the system databases from the C drive to the H and O drives for my data and log files respectively. (Original is seen in top line A and modified line is B)
- –dC:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA\master.mdf;-eC:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\Log\ERRORLOG;-lC:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA\mastlog.ldf
- -dH:\Program Files\MSSQL10_50.MSSQLSERVER\MSSQL\DATA\master.mdf;-eC:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\Log\ERRORLOG;-lO:\Program Files\MSSQL10_50.MSSQLSERVER\MSSQL\TLogs\mastlog.ldf
- –dC:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA\master.mdf;-eC:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\Log\ERRORLOG;-lC:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA\mastlog.ldf
-
You will need to copy and paste the line by using the select all option (right click to bring up the menu)
Image may be NSFW.
Clik here to view.
- Then you can do a control-c to copy to notepad to modify the parameters (Line A above) and then control-v to paste the new desired line into new startup (Line B above)
- Before you start the service, you will need to manually copy the master.mdf and mastlog.ldf files to the new locations
- Now start the service and all is well
Moving the Model and MSDB Database
To move the master database, please follow these steps.
-
Check current location of MSDB & Model Databases by executing below query:
Image may be NSFW.
Clik here to view.
Image may be NSFW.
Clik here to view.
NOTE: You can also use “Execc SP_HelpDB ‘<DBNAME>’ for these details.
As you can see I placed a lot of files on my E drive, which I normally use for my backup drive. I need to fix that to align myself with best practices and also better performance.
-
Run this command to update the system databases
Image may be NSFW.
Clik here to view.
Note: It will update the system catalog
Image may be NSFW.
Clik here to view.
- Stop SQL Services
- Manually Move MSDB and Model Databases files to the new location
- Start SQL Services
-
Check MSDB & Model Databases file location after movement
Image may be NSFW.
Clik here to view.