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 DATABASEstatement 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:
1
2
3
4
| USE master GO SELECT * FROM sys.database_files |
–> 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.
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 toE:\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
-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
-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:
1
2
3
4
| USE master GO SELECT * FROM sys.database_files |
No comments:
Post a Comment