Click here to Skip to main content
Click here to Skip to main content

Rebuilding Master Database in SQL Server

By , 17 Aug 2013
Rate this:
Please Sign up or sign in to vote.

Introduction

In this tip, I would like to show you how to rebuild the master/system database in SQL Server 2008 R2. Recently, I faced a problem related to the master database. My instance was unable to start due to master file corruption.

Case Study

Recently, one of my instances was corrupted and I was unable to restart SQL Server. I did the following steps to get it back. First I checked the SQL Server ERRORLOG. Please go through the following steps.

Step 1: Check the error log where it is showing master was corrupted.

Step 2: Rebuild system databases from command prompt. Go to the following path and run setup as follows:

C:\Program Files\Microsoft SQL Server\100\Setup Bootstrap\SQLServer2008R2

Step 3: Once the above command runs successfully, check in the summary.txt file as follows and look at the Requested action.

Step 4: Start SQL Server service.

Step 5: Connect to the instance. But you cannot see any user defined databases. The rebuilding process has created a fresh master database so there are no other databases and all previous configuration values are lost.

Step 6: Now we can restore the master database to get the previous configuration settings. Go to command prompt and run server in single user mode as follows:

Step 7: Connect to the instance and take new query to restore master database. Once we restore master database, then we can get all the previous configuration values including user defined databases.

Step 8: Click on Connect button and connect to the instance as follows:

Step 9: Restore master database as follows

Step 10: Restart SQL Server instance in multi user mode and connect to SQL Server Management Studio. We can see all user databases as follows:

Troubleshooting

Sometimes, the rebuild process may fail if there is problem with files present in Binn\Templates folder. Once you check summary.txt file, let's say it is saying one message as follows:

Configuration error description: The file C:\Program Files\Microsoft SQL Server \
MSSQL10_50.MSSQLSERVER \MSSQL\Binn\Templates\master.mdf is missing

In the above scenario, we have to copy file (master.mdf) from SQL Server dump or DVD into Binn\Templates folder and retry.

Summary

We can summarize the key points as follows according to BOL regarding rebuilding system databases:

  • SQL Server 2000
    • We can use RebuildM.exe
    • Need setup media for system database files
  • SQL Server 2005
    • We can use setup.exe
    • Need setup media for setup.exe and system database files
  • SQL Server 2008
    • We can use setup.exe
    • Setup media not required and system database files are there in Binn\Templates folder

Happy learning!

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

Kareem.S
Instructor / Trainer OptimizeSQL Technologies
India India
Mr. Kareem Syed is a senior SQL Server Trainer and working as Technical Consultant.
 
You can visit my blog at
www.optimizesql.blogspot.in
Follow on   Twitter

Comments and Discussions

 
Questionvery very good Pinmemberyahya_iranmanesh26-Jun-13 23:47 
QuestionGreat guide PinmemberMember 1004948813-May-13 10:42 
SuggestionOne another solution PinmemberAdam Gorge17-Feb-13 23:22 
QuestionThe formatting... PinmvpOriginalGriff31-Jan-13 8:18 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Mobile
Web01 | 2.8.140421.2 | Last Updated 17 Aug 2013
Article Copyright 2013 by Kareem.S
Everything else Copyright © CodeProject, 1999-2014
Terms of Use
Layout: fixed | fluid