You can rebuild the master database by using SQL Server or SQL Server Express.
Before You Begin
You must rebuild the Operating System
Procedure
If the Master Database Exists
-
Insert the SQL Server installation media into the disc drive.
Note
If you are using SQL Server Express, download the Express kit and extract the contents to a local directory.
-
At a command prompt, go to the disc drive or the extracted directory and based on the SQL Server version, run the appropriate command for rebuilding the master database.
For SQL 2005:
start /wait setup.exe /qn INSTANCENAME=<InstanceName> REINSTALL=SQL_Engine REBUILDDATABASE=1 SAPWD=<NewStrongPassword> REINSTALLMODE=vomus
where:
/qn = suppresses all setup dialog boxes and error messages.
/qb = allows display of basic setup dialog boxes and error messages.
For SQL 2008 and later:
Setup /QUIET /ACTION=REBUILDDATABASE /INSTANCENAME=InstanceName /SQLSYSADMINACCOUNTS=accounts [ /SAPWD=StrongPassword ] [ /SQLCOLLATION=CollationName ]
where:
/QUIET or /Q = means the setup runs without any user interface.
-
At a command prompt, run Services.msc
-
Right-click the SQL Server instance and select Start.
If the Master Database Does Not Exist
In cases when the master database is not available, use the following steps to rebuild the master database:
-
Go to the directory where the SQL Server is installed.
For example, C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL
-
Open the Template Data folder and verify that there are copies of the system databases that were created automatically during the original install.
-
Copy the missing files to the Data directory.
By default, the data directory is: C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data
Note
Ensure that the default filters for SQL are not added, as these filters can cause the necessary files to get excluded. For more information on the default SQL filters, see Microsoft SQL Server,Content, Filters, and Regular Expressions - Best Practices.
-
At a command prompt, run Services.msc
-
In the Services window, right-click the SQL Server instance, and select Start.
What to Do Next
After you rebuild the master database, use the steps in Restoring the SQL Server Instance to restore the data.