SQL Server – Cannot Recover the Master Database

Was recently patching my SQL Server 2014 instance with Service Pack 2 in my lab, when I noticed I couldn’t start SQL Server post patching installation.

As i couldnt start SQL Server, i couldnt check the SQL Server Logs. Luckily i remembered that the SQL logs are physically stored where the SQL Server binaries are kept.

Found the Error.log under
D:\Program Files\Microsoft SQL Server\MSSQL10_50.VMWare\MSSQL\Log

MasterDatabaseCorrupt#1

Looks like the database is corrupted. Cannot recover the master database isnt a great message.

MasterDatabaseCorrupt#2

Normally I would restore the system database from backup, but in this case I was in an environment that didn’t have any backups available.

Solution:

To resolve, we need to rebuild the master database.

Pre-Reqs:

  1. SA password is known;
  2. SA account is enabled;
  3. SQL Server installation media for the particular SQL version is mounted.

To rebuild the master database we need to run the below command in an elevated command prompt:

  1. Navigate to the setup.exe is within the installation media.

          CD E:

  1. Now run the command to rebuild the database.
    ./setup /ACTION=REBUILDDATABASE /INSTANCENAME=<instance_name> /SQLSYSADMINACCOUNTS=<admin_account> /SAPWD=<sa_password>

You should now be able to start SQL Server with no issues.