How to restore Master db in SQL Server 2008 Express?

535 Views Asked by At

Please can I ask for your assistance in investigating as to why I cannot restore the master db from a recent backup?

Physical copies taken of .mdf and .ldf master files (just in case!) and then I've recreated a corrupted master database by manually deleting content from the .mdf file using Notepad to simulate disk corruption.

Subsequently, SQL Server (MSSQLSERVER) service will not start which is the scenario I'm trying to resolve.

Actions taken to backup Master database:

Prior to corrupting master, a backup was taken using following command:

BACKUP DATABASE master 
TO DISK = 'C:\Temp\MasterBK.DAT' 
WITH FORMAT, NAME = 'Full Backup of master'

Actions taken to restore:

Various different attempts to start SQL Servre service in single-user mode, including:

-mSQLCMD 
-m"SQLCMD"
sqlservr.exe -m
NET START MSSQLSERVER /m

Tried adding -m into Startup Parameters in SQL Server Configuration Manager

Error received on restore

-mSQLCMD is not a recognised as an internal or external command
Service did not start in a timely manner

Version Information:

[Windows XP]

Microsoft SQL Server 2008 (SP1) - 10.0.2531.0 (Intel X86) 
Express Edition on Windows NT 5.1 <X86> (Build 2600: Service Pack 3)
2

There are 2 best solutions below

2
Anonymous Duck On
  1. Please confirm if your backup is right, and then delete the current database (the one which is corrupted).

  2. Restore DB using its .LDF and .MDF physical files:

    CREATE DATABASE DIS 
       ON (FILENAME = 'C:\DIS.mdf'), 
          (FILENAME = 'C:\DIS_1.LDF') 
       FOR ATTACH;
    

Please give a try.

For service not running, try to open windows services and look for your SQL Server service there or just go SQL Server Configuration Manager.

To run sql server in single user mode, check this post https://mssqlfun.com/2014/09/04/how-to-start-sql-server-in-single-user-mode/.

Your cmd commands might not work because you're not on the right directory where this executables resides.

2
Ruhaan On