Home > DBA Stuff > SQL DBA – Move master Database to another drive – in simple steps

SQL DBA – Move master Database to another drive – in simple steps


 
Well, there are times when you want to move your master database from the default location to some other drive. Now this activity cannot be done with the normal ALTER DATABASE statement with MODIFY FILE option. And you need a spacial handling for this case of master DB.
 


 

–> Let’s first check the location of master DB:

USE master
GO

SELECT * FROM sys.database_files

Move Master 01
 

–> Now leave SSMS, and open SSCM i.e. SQL Server Configuration Manager. Here select “SQL Server Service”, and Rigth Click on the instance of SQL Server, and choose Properties. Now select the Startup Parameters tab.

Move Master 02

Here you will see 3 line items:

1. -d is the path of the master data file.

2. -e is the path of the SQL error log file.

3. -l is the path of the master log file.

So, you need to update the 1st and 3rd ones. As I want to move my files to E:\SystemDatabases\Master\ location, so you just need to replace the existing path with following:

1. master data File:
-dC:\Program Files\Microsoft SQL Server\MSSQL13.MSSQLSERVER\MSSQL\DATA\master.mdf
-dE:\SystemDatabases\Master\master.mdf

2. master Log File:
-lC:\Program Files\Microsoft SQL Server\MSSQL13.MSSQLSERVER\MSSQL\DATA\mastlog.ldf
-lE:\SystemDatabases\Master\mastlog.ldf
 

–> Now Stop the SQL Server services, by going to: RUN –> services.msc

–> Manually Copy the master.mdf & mastlog.ldf files to the new location

–> Start the SQL Server services.

–> To confirm the new location, just execute following query and check the path:

USE master
GO

SELECT * FROM sys.database_files

Master DB move 03
 


Advertisement
Categories: DBA Stuff Tags:
  1. easyoradba
    October 14, 2016 at 3:03 pm

    Reblogged this on SimpleSQLDBA | Shadab Mohammad.

  2. Harrishilton
    March 12, 2018 at 3:30 pm

    what about model database

  3. k3nn
    November 9, 2021 at 8:12 am

    all good. and the query returns the new path being run BUT i can’t delete the old mdf and ldf files. since it was copied over to the ew drive and is actually running, the old files in c would be deleted but somehow I can’t 😦 error said it is being used by sql service

  1. June 29, 2016 at 9:58 am

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: