Live Chat
Home » Blog » SQL Server » How to Rebuild Master Database in SQL Server with Advance Methods
SQL Server

How to Rebuild Master Database in SQL Server with Advance Methods

Published By Mohit Jha
Tej Pratap Shukla
Approved By Tej Pratap Shukla
Published On December 18th, 2021
Reading Time 5 Minutes Reading

It is usually noticed that a majority of SQL Server administrators back up their data at a regular period of time. Well, some of them do not understand the value of data backup and loss their databases in case of any mishappening. But, whatever be the issues, in this post we walk you through the entire process on how to rebuild master database in SQL server in a step-by-step manner.

Figure Out Whether Master Database is Damaged or Not

Before going to know, how to restore master database in SQL Server let us discuss the signs and symptoms to determine whether the master database is corrupted or not. Some of the indications are written below:

  • The chances of segmentation faults or Input/Output errors
  • Fail to start SQL server
  • Generation of a report by checker tool of database consistency
  • Power Surge

However, a user can identify the error log to know about the cause of corruption.

Workaround Method to Rebuild Master Database in SQL Server

The entire process to re-establish master database is divided into 3 different parts. Each part is explained separately.

Part 1: Before Rebuilding Process

As master database is corrupted. So, in order to prevent loss of other files, it is essential to take backup of them. The files which are to be backed up are MSDB data, MSDB Log, model log in & model. To obtain the backup, execute the following steps:

    • Launch SQL server configuration manager on the system
    • From the left-hand side pane, choose an option of SQL Server services. This will generate a list of overall services that are executing presently
    • Right-click on the desired service and choose the option of Stop to halt the services one by one
    • Exit from SQL server configuration manager to restore master database in SQL server Go to the location where the system files of any specific SQL server instance are saved

Note: The location where master database will be rebuilt automatically is
C:\Program Files\Microsoft SQL Server\[INSTANCE NAME]\MSSQL\DATA

  • Extract all the healthy files and save them in a separate folder. Delete the corrupted master mastlog, templog, tempdb files

Part 2: Rebuilding Process

Users have to follow these steps to rebuild master database in SQL server :

    • In the command window, modify the directory location of the server instance. Insert the location where installation media of SQL server 2016 is present
    • Open Command Prompt as administrator program
    • Alter the directory location by entering the drive where installation media is present. Then, press on Enter
    • In the next step, execute the following command:

Rebuild Master Database in SQL Server

Note: Remember that if the account name comprises of a blank space, do not forget to confine the name of the account within quotes. Additionally, if more than one account is specified, you have to separate them using a space to rebuild master database in SQL server.

    • At the time when all the databases are rebuilt, no message is returned in the command prompt. If you want to check whether the procedure is accomplished successfully, identify the summary.txt file. The location for this file is:

C:\Program Files\Microsoft SQL Server\130\Setup Bootstrap\Logs

Part 3: After Rebuild Process

Once the rebuilding process is done, execute the following operations:

  1. Restart all the services which were halted previously after master database is rebuild
  2. Restore the backups of model and MSDB database
  3. If a backup of the data is not present, you can simply replace the model files and rebuild MSDB with the files obtained while backing up in the first section. This step has to be performed after pausing the services.

Smart Strategy to Rebuild Master Database in SQL Server

The manual solution explained above is lengthy and performing it is a tedious task. Moreover, technical expertise is demanded to fulfill this operation. Hence, to avoid such issues, users can go with another solution like SQL Database recovery tool. It is easy to handle application and recovery damaged and corrupt SQL database files without any data loss and does not make any changes to the original content. With this software users can also recover the permanently deleted database items and export them directly to live SQL Server environment , CSV File or as SQL Script. It fulfills all types of SQL database recovery needs. This software is very effective & reliable to repair and export data into SQL Server present in the same machine or a server network. Hence, this is the professional tool to restore master database in SQL Server.

Download Purchase Now

Both primary and secondary databases can be repaired using this third-party utility. It scans and extracts triggers, rules, tables, functions, stored procedures and much more data from SQL database files. The program is compatible with all the editions of SQL Server like 2019, 2017, 2016, 2014, 2012, and other versions beneath them. SQL database recovery software is also compatible with ASCII and Unicode XML data types.

Note: The user can also read how to recover deleted records in SQL Server

Wrapping Up

Many times, DBA or SQL users search for an answer when the MDF file is corrupted and the only option to solve it is to restore master database in SQL Server. The post explains an entire manual workaround solution to rebuild master database in SQL server 2019, 2017, 2016 & its below version. But, there are some shortcomings to this approach. Hence, an automated tool is also introduced to repair and rebuild the master database in MS SQL server.


By Mohit Jha

Mohit is a Microsoft-certified expert who has assisted thousands of clients with Outlook & Microsoft Office 365 issues. He enjoys writing on email clients as well as data migration. He is always excited about giving troubled readers the most up-to-date knowledge, explanation, and refinements.