[Solved] How to Restore Master Database in SQL Server 2008/2012 - Qiling  

How to Restore Master Database in SQL Server 2008/2012 with or Without Backup


The solution is applicable to various versions of MS SQL Server, including 2016, 2014, 2012, 2008, 2008 R2, and 2005.

The master database file (MDF) is the primary user database file that holds the main configuration details and all major data of SQL Server. If the server experiences a sudden shutdown, crash, or is affected by a virus, the MDF file can become corrupted or damaged. In such cases, restoring the MDF file is the most effective approach to resolve the issue.

how to restore master database in SQL server

How to Restore the SQL Server Master Database with or Without Backup

Restoring the master database in SQL Server 2008 or 2012 can be achieved in two ways. Either you can restore the master database from a backup file, or you can restore the MDF file without a backup. Depending on your situation, you can choose one of these two methods to resolve the issue.

Solution 1. Restore Master Database in SQL Server from Backup File

If you have a backup of the SQL server master database, you can easily restore the MDF file by following a few simple steps. Simply copy the backup file to the server, open SQL Server Management Studio, right-click on the server name in the Object Explorer, and select "Tasks" > "Restore" from the context menu.

Notice:
If you haven't created a backup of your SQL Server database, you can skip this method and use Solution 2 to restore the master database in SQL Server without a backup file.

Step 1. Set your SQL server instance in single-user mode.

how to restore SQL server master database

Step 2. Run Transact-SQL command to restore SQL server master database.

RESTORE DATABASE master FROM WITH REPLAC

The "replace" command in the restoration process continues even if there is a database with the same name, and the existing database will be removed.

Step 3. Set Microsoft SQL Server to Multi-User Mode.

After the master database restoration is complete, the SQL Server instance will shut down. To proceed, remove the single-user startup parameter and set the server to multi-user mode before restarting it.

SQL Server (MSSQLSERVER)

SQL Server Agent (MSSQLSERVER)

SQL Server Reporting Services (MSSQLSERVER)

Step 4. Restart the SQL Server instance and perform other recovery tasksif you want.

Solution 2. Restore SQL Server Master Database Without Backup File

If you're new to SQL Server or haven't created a backup, you can still restore the master database using the Qiling MS SQL Recovery tool. This professional software can recover MDF files and their components, including tables, triggers, indexes, keys, rules, and stored procedures, as well as deleted records from the SQL database.

Step 1. Stop MS SQL Server service via services.msc or Management Studio.

Step 2. Run Qiling SQL Recovery, select the MDF/NDF file of the database you want to restore, and click "Repair" to start repairing your MDF/NDF file in the main interface.

If you know the exact location of the file, click "Browse" to locate the database. This will allow you to select the file from your computer and upload it to the system.

If you're unsure about the location of the file, click on the "Search" button to search for the .mdf or .ndf file in your system.

Select file types that you want to recover

Step 3. After the recovery process is complete, the recovered database objects will be listed in the left pane of the window, allowing you to see the results of the operation.

select a location where you deleted files

Step 4. To export your database objects, click the "Export" button located in the bottom right corner of the screen. This will allow you to save your database objects in a preferred format, such as MDF (Microsoft Database File) or SQL scripts.

On the "Export to database" window, choose "Create new database" to create a new database and enter the database name and SQL location, or select "Export to existing database" to export to an existing database, selecting the database from the list.

Recover deleted files

Step 5. Now restart the SQL Server.

Related Articles


Is this information helpful?     

What can we do to improve this information? (Optional)
Refresh Please enter the verification code!


QilingTech uses cookies to ensure you get the best experience on our website.  Learn more  Got it