{"id":122765,"date":"2023-02-02T06:02:12","date_gmt":"2023-02-02T06:02:12","guid":{"rendered":"https:\/\/www.stellarinfo.com\/blog\/?p=122765"},"modified":"2026-06-26T07:35:25","modified_gmt":"2026-06-26T07:35:25","slug":"how-to-rebuild-and-restore-master-database-in-sql-server","status":"publish","type":"post","link":"https:\/\/www.stellarinfo.com\/blog\/how-to-rebuild-and-restore-master-database-in-sql-server\/","title":{"rendered":"How to Rebuild and Restore Master Database in SQL Server?"},"content":{"rendered":"<?xml encoding=\"utf-8\" ?><?xml encoding=\"utf-8\" ?><p class=\"wp-block-paragraph\">In Microsoft SQL Server, the master database is the primary system database that contains <code>master.mdf<\/code> (data file) and <code>mastlog.ldf<\/code> (log file). Master database is important because it records:<\/p><ul class=\"wp-block-list\">\n<li>Server login accounts and their properties<\/li>\n\n\n\n<li>Linked server definitions and endpoints<\/li>\n\n\n\n<li>Error messages and system stored procedures<\/li>\n\n\n\n<li>Startup procedures and configuration settings<\/li>\n<\/ul><p class=\"wp-block-paragraph\">Without this database, the SQL Server service or instance may not start. Also, the other databases can become inaccessible. If the master database gets corrupted, you may encounter log errors, such as:<\/p><ul class=\"wp-block-list\">\n<li>&ldquo;Cannot open database &lsquo;master&rsquo; requested by the login. The login failed.&rdquo;<\/li>\n\n\n\n<li>&ldquo;SQL Server cannot start because it cannot open the master database.&rdquo;<\/li>\n\n\n\n<li>This makes recovering master database in SQL a top priority for DBAs and sysadmins.<\/li>\n<\/ul><p class=\"wp-block-paragraph\">In this guide, we&rsquo;ll cover the causes of corruption in the master database and how to repair, restore, and rebuild it in SQL Server.<\/p><h2 class=\"wp-block-heading\" id=\"what-causes-master-database-corruption-or-failure?\">What Causes Master Database Corruption or Failure?<\/h2><p class=\"wp-block-paragraph\">Corruption in master database can be caused due to several reasons. Identifying the cause helps you choose the correct recovery method. Common reasons include:<\/p><ul class=\"wp-block-list\">\n<li><strong>Abrupt SQL Server shutdown:<\/strong> Power failure or OS crash while master database is being written can cause file-level corruption.<\/li>\n\n\n\n<li><strong>Disk failure or bad sectors<\/strong>: Hardware or storage errors directly damage the master.mdf or mastlog.ldf files.<\/li>\n\n\n\n<li><strong>Accidental deletion<\/strong>: Administrators may mistakenly delete or move master database files.<\/li>\n\n\n\n<li><strong>Sudden system shutdown<\/strong>: A sudden restart of the SQL Server instance or abrupt system shutdown while working on master database.<\/li>\n\n\n\n<li><strong>Virus or ransomware attack<\/strong>: Malware or virus infection in the system hosting the database\/server.<\/li>\n\n\n\n<li><strong>Full transaction log<\/strong>: When mastlog.ldf fills up, SQL Server may mark the database as suspect.<\/li>\n<\/ul><h2 class=\"wp-block-heading\" id=\"methods-to-rebuild-or-restore-the-master-database-in-sql-server\">Methods to Rebuild or Restore the Master Database in SQL Server<\/h2><p class=\"wp-block-paragraph\">Recovery of the corrupt master database, depends on the situation &mdash; whether SQL Server can start, a backup exists, or the damage is severe. You can run <a href=\"https:\/\/learn.microsoft.com\/en-us\/sql\/t-sql\/database-console-commands\/dbcc-checkdb-transact-sql?\" target=\"_blank\" rel=\"noreferrer noopener nofollow\">DBCC CHECKDB<\/a> on the master database to check its integrity but, you cannot directly repair the master database with it. It is not supported for master as it contains startup and configuration files.<\/p><p class=\"wp-block-paragraph\">If the server installation files in master database are corrupted, you can repair them with the installer. If the backup is available, then <a href=\"https:\/\/www.stellarinfo.com\/blog\/how-to-backup-and-restore-sql-server-database\/\" id=\"https:\/\/www.stellarinfo.com\/blog\/how-to-backup-and-restore-sql-server-database\/\" target=\"_blank\" rel=\"noreferrer noopener\">restore from backup<\/a>. If you&rsquo;re not able to start the server and backup is also not available, then rebuild it using the setup command line or use Stellar Repair for MS SQL. Each method has its own prerequisites and results. Below are the methods to rebuild or restore the SQL Server master database:<\/p><h3 class=\"wp-block-heading\">Method 1: Repair Master Database using SQL Server Setup Installer<\/h3><p class=\"wp-block-paragraph\">The SQL Server installer includes a built in repair function that re-registers SQL Server components, corrects corrupted system database files including master database, and fixes missing or damaged installation files. Repairing master database using this method does not require a backup file. It does not delete user data. To use this method, there&rsquo;s no need to start the SQL Server service.<\/p><p class=\"wp-block-paragraph\"><strong>Prerequisites:<\/strong><\/p><ul class=\"wp-block-list\">\n<li>Select all server-side configuration values.<\/li>\n\n\n\n<li>Note down the location of all the data and log files in the system database.<\/li>\n\n\n\n<li>Access to the original SQL Server installation media or ISO.<\/li>\n<\/ul><p class=\"wp-block-paragraph\">To repair the corrupted server installation files in master database using the MS SQL Server Installer, follow these steps:<\/p><ul class=\"wp-block-list\">\n<li>On your system, go to the <strong>SQL Server installer folder<\/strong> and then click on <strong>setup.exe.<\/strong><\/li>\n<\/ul><figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1013\" height=\"455\" src=\"https:\/\/www.stellarinfo.com\/blog\/wp-content\/uploads\/2023\/02\/go-SQLServerInstallerfolder.png\" alt=\"Under SQL Server installer folder, Click Setup.exe \" class=\"wp-image-193575 apply-gradient-on-post-images\" srcset=\"https:\/\/www.stellarinfo.com\/blog\/wp-content\/uploads\/2023\/02\/go-SQLServerInstallerfolder.png 1013w, https:\/\/www.stellarinfo.com\/blog\/wp-content\/uploads\/2023\/02\/go-SQLServerInstallerfolder-300x135.png 300w, https:\/\/www.stellarinfo.com\/blog\/wp-content\/uploads\/2023\/02\/go-SQLServerInstallerfolder-768x345.png 768w\" sizes=\"auto, (max-width: 1013px) 100vw, 1013px\" \/><\/figure><ul class=\"wp-block-list\">\n<li>The <strong>SQL Server Installation Center<\/strong> window is displayed. Click <strong>Maintenance<\/strong> and then click the <strong>Repair <\/strong>option<strong>.<\/strong><\/li>\n<\/ul><figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"773\" src=\"https:\/\/www.stellarinfo.com\/blog\/wp-content\/uploads\/2023\/02\/click-maintenance-option-in-SQL-server-installation-center.png\" alt=\"Repair under Maintenance section in SQL Server Installation Center\" class=\"wp-image-193579 apply-gradient-on-post-images\" srcset=\"https:\/\/www.stellarinfo.com\/blog\/wp-content\/uploads\/2023\/02\/click-maintenance-option-in-SQL-server-installation-center.png 1024w, https:\/\/www.stellarinfo.com\/blog\/wp-content\/uploads\/2023\/02\/click-maintenance-option-in-SQL-server-installation-center-300x226.png 300w, https:\/\/www.stellarinfo.com\/blog\/wp-content\/uploads\/2023\/02\/click-maintenance-option-in-SQL-server-installation-center-768x580.png 768w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure><ul class=\"wp-block-list\">\n<li>Select the server instance you want to repair and click <strong>Next.<\/strong><\/li>\n<\/ul><figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"808\" height=\"610\" src=\"https:\/\/www.stellarinfo.com\/blog\/wp-content\/uploads\/2023\/02\/select-instance-you-want-to-repair-click-next.png\" alt=\"Select Instance you want to repair and click Next\" class=\"wp-image-193584 apply-gradient-on-post-images\" srcset=\"https:\/\/www.stellarinfo.com\/blog\/wp-content\/uploads\/2023\/02\/select-instance-you-want-to-repair-click-next.png 808w, https:\/\/www.stellarinfo.com\/blog\/wp-content\/uploads\/2023\/02\/select-instance-you-want-to-repair-click-next-300x226.png 300w, https:\/\/www.stellarinfo.com\/blog\/wp-content\/uploads\/2023\/02\/select-instance-you-want-to-repair-click-next-768x580.png 768w\" sizes=\"auto, (max-width: 808px) 100vw, 808px\" \/><\/figure><ul class=\"wp-block-list\">\n<li>The <strong>Ready to Repair<\/strong> window appears on the screen. You can verify the details and then click on the <strong>Repair<\/strong> option.<\/li>\n<\/ul><figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"808\" height=\"610\" src=\"https:\/\/www.stellarinfo.com\/blog\/wp-content\/uploads\/2023\/02\/click-repair-on-ready-to-repair-window.png\" alt=\"Repair on ready window to repair SQL server installation files\" class=\"wp-image-193589 apply-gradient-on-post-images\" srcset=\"https:\/\/www.stellarinfo.com\/blog\/wp-content\/uploads\/2023\/02\/click-repair-on-ready-to-repair-window.png 808w, https:\/\/www.stellarinfo.com\/blog\/wp-content\/uploads\/2023\/02\/click-repair-on-ready-to-repair-window-300x226.png 300w, https:\/\/www.stellarinfo.com\/blog\/wp-content\/uploads\/2023\/02\/click-repair-on-ready-to-repair-window-768x580.png 768w\" sizes=\"auto, (max-width: 808px) 100vw, 808px\" \/><\/figure><h3 class=\"wp-block-heading\"><strong>Method 2: Restore the Master Database from Backup<\/strong><\/h3><p class=\"wp-block-paragraph\">If you have a readable backup of the master database, you can restore it using <a href=\"https:\/\/learn.microsoft.com\/en-us\/sql\/tools\/sqlcmd\/sqlcmd-utility?\" id=\"https:\/\/learn.microsoft.com\/en-us\/sql\/tools\/sqlcmd\/sqlcmd-utility?\" target=\"_blank\" rel=\"noreferrer noopener nofollow\">SQLCMD<\/a> in single&#8209;user mode. Unlike restoring a user database, the master database cannot be restored while SQL Server is running in multi&#8209;user mode &mdash; the service must be started with the -m (single&#8209;user) parameter first.<\/p><p class=\"wp-block-paragraph\"><strong>Prerequisite:&nbsp;<\/strong><\/p><p class=\"wp-block-paragraph\">You must have a master.bak file taken from the same SQL Server version. If there is version mismatch, then you can encounter the error.<\/p><p class=\"wp-block-paragraph\">Follow the steps cited below to restore the master database in MS SQL Server:<\/p><p class=\"wp-block-paragraph\"><strong>&nbsp;Step 1<\/strong>: Open the Configuration Manager on your system, click SQL Server Services, select and right-click on the instance. Click <strong>Stop.<\/strong><\/p><figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"504\" src=\"https:\/\/www.stellarinfo.com\/blog\/wp-content\/uploads\/2023\/02\/click-stop-services-under-sqlserverservices-in-configuration-manager.png\" alt=\"Click Stop to stop services in-SQL Server Configuration Manager\" class=\"wp-image-193596 apply-gradient-on-post-images\" srcset=\"https:\/\/www.stellarinfo.com\/blog\/wp-content\/uploads\/2023\/02\/click-stop-services-under-sqlserverservices-in-configuration-manager.png 1024w, https:\/\/www.stellarinfo.com\/blog\/wp-content\/uploads\/2023\/02\/click-stop-services-under-sqlserverservices-in-configuration-manager-300x148.png 300w, https:\/\/www.stellarinfo.com\/blog\/wp-content\/uploads\/2023\/02\/click-stop-services-under-sqlserverservices-in-configuration-manager-768x378.png 768w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure><p class=\"wp-block-paragraph\"><strong>Step 2 &ndash; <\/strong>Right-click the instance again and select&nbsp;<strong>Properties.<\/strong><\/p><figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"623\" height=\"401\" src=\"https:\/\/www.stellarinfo.com\/blog\/wp-content\/uploads\/2023\/02\/right-click-instance-again-and-click-properties.png\" alt=\"Right-click on Instance to open properties \" class=\"wp-image-193603 apply-gradient-on-post-images\" srcset=\"https:\/\/www.stellarinfo.com\/blog\/wp-content\/uploads\/2023\/02\/right-click-instance-again-and-click-properties.png 623w, https:\/\/www.stellarinfo.com\/blog\/wp-content\/uploads\/2023\/02\/right-click-instance-again-and-click-properties-300x193.png 300w\" sizes=\"auto, (max-width: 623px) 100vw, 623px\" \/><\/figure><p class=\"wp-block-paragraph\">Click <strong>Startup Parameters<\/strong>, specify the -m parameter in field under &ldquo;<strong>Specify a startup parameter<\/strong>, and then click <strong>Add.<\/strong><\/p><figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"620\" height=\"786\" src=\"https:\/\/www.stellarinfo.com\/blog\/wp-content\/uploads\/2023\/02\/specify-a-startup-parameter-under-startup-parameters.png\" alt=\"Specify a Startup Parameter UndeR Startup Parameters\" class=\"wp-image-193627 apply-gradient-on-post-images\" srcset=\"https:\/\/www.stellarinfo.com\/blog\/wp-content\/uploads\/2023\/02\/specify-a-startup-parameter-under-startup-parameters.png 620w, https:\/\/www.stellarinfo.com\/blog\/wp-content\/uploads\/2023\/02\/specify-a-startup-parameter-under-startup-parameters-237x300.png 237w\" sizes=\"auto, (max-width: 620px) 100vw, 620px\" \/><\/figure><p class=\"wp-block-paragraph\">Here,&nbsp;<strong>-m<\/strong>&nbsp;is used to set the instance to single-user mode.<\/p><p class=\"wp-block-paragraph\"><strong>Step 3 <\/strong>&ndash; Optionally, you can use the -f start option to set the instance with minimal configurations.<\/p><p class=\"wp-block-paragraph\"><strong>Step 4 <\/strong>&ndash; Run the following commands in CMD:<\/p><p class=\"wp-block-paragraph\"><code>NET STOP MSSQLSERVER<\/code><\/p><p class=\"wp-block-paragraph\"><code>NET START MSSQLSERVER \/m<\/code><\/p><p class=\"wp-block-paragraph\">Replace the SQL Server instance name with your own server name; in my case, it is MSSQLServer.<\/p><p class=\"wp-block-paragraph\"><strong>Step 5<\/strong>: Once the database is in single-user mode, you can connect with the SQLCMD and restore the database by using the following command:<\/p><p class=\"wp-block-paragraph\"><code>SQLCMD -S MSSQLServer -E -d master<\/code><\/p><p class=\"wp-block-paragraph\">Here,<\/p><p class=\"wp-block-paragraph\">MSSQLSERVER is the server&rsquo;s name.<\/p><p class=\"wp-block-paragraph\">-E is to connect with Windows Authentication.<\/p><p class=\"wp-block-paragraph\">-S is to provide the instance name.<\/p><p class=\"wp-block-paragraph\">-d is to specify the database to connect.<\/p><p class=\"wp-block-paragraph\"><strong>Step 6 &ndash;<\/strong> Verify the backup file is accessible before restoring using the following command:<\/p><p class=\"wp-block-paragraph\"><code>RESTORE HEADERONLY FROM DISK = 'c:\\stellarbackups\\master.bak';&nbsp;<\/code><\/p><p class=\"wp-block-paragraph\"><code>GO&nbsp;<\/code><\/p><p class=\"wp-block-paragraph\"><strong>Step 7 <\/strong><em>&ndash;<\/em> Finally, run the below restore command to restore the database.<\/p><p class=\"wp-block-paragraph\"><code>restore database master from disk = 'c:\\stellarbackups\\master.bak' with replace;<\/code><\/p><p class=\"wp-block-paragraph\"><strong>Step 8<\/strong>: Once you have restored the master database from backup, perform the below actions:<\/p><ul class=\"wp-block-list\">\n<li>Restart the server instance normally without using startup parameters.<\/li>\n\n\n\n<li>Make sure you&rsquo;ve restored the recent full backup.<\/li>\n\n\n\n<li>Save the restored master database to the original location.<\/li>\n\n\n\n<li>Check and match the server-side configuration values with the previous configuration values.<\/li>\n<\/ul><h3 class=\"wp-block-heading\"><strong>Method 3: Rebuild Master Database using the Setup Command Line<\/strong><\/h3><p class=\"wp-block-paragraph\">You can use the command line to rebuild SQL Server when the master database is severely damaged and no backup file exists. It helps you rebuild the master database to its default state, recreating system objects and configuration settings from scratch. While it helps you start your SQL Server, it also delete server&#8209;level data such as logins and custom configurations. So, you need to recreate them manually.<\/p><p class=\"wp-block-paragraph\"><strong>Prerequisite:<\/strong><\/p><p class=\"wp-block-paragraph\">You need access to the original SQL Server installation media.<\/p><p class=\"wp-block-paragraph\">To run the SQL Server Installer in the Command Prompt, use the below command:<\/p><p class=\"wp-block-paragraph\"><code>setup \/QUIET \/ACTION=REBUILDDATABASE \/INSTANCENAME=MSSQLServer \/SQLSYSADMINACCOUNTS=sa&nbsp; \/SAPWD= MyP983&rdquo;#3&nbsp; \/SQLCOLLATION=Latin1_General_CI_AS<\/code><\/p><p class=\"wp-block-paragraph\">Check the <strong>parameter explanation table<\/strong> below, to understand each part of the command:<\/p><figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><tbody><tr><td><strong>Parameter<\/strong><\/td><td><strong>Value<\/strong><\/td><td><strong>Explanation<\/strong><\/td><\/tr><tr><td><strong>\/ACTION=REBUILDDATABASE<\/strong><strong><\/strong><\/td><td>(fixed)<\/td><td>Triggers the rebuild action for system databases.<\/td><\/tr><tr><td><strong>\/INSTANCENAME=<\/strong><strong><\/strong><\/td><td>MSSQLServer<\/td><td>Your SQL Server instance name. Default: <code>MSSQLSERVER<\/code>. For named instances, e.g. <code>INSTANCENAME=SQLEXPRESS<\/code>.<\/td><\/tr><tr><td><strong>\/SQLSYSADMINACCOUNTS=<\/strong><strong><\/strong><\/td><td>Sa<\/td><td>The Windows or SQL account to be added as sysadmin after rebuild.<\/td><\/tr><tr><td><strong>\/SAPWD=<\/strong><strong><\/strong><\/td><td>Your SA password<\/td><td>Required if Mixed Mode authentication is enabled.<\/td><\/tr><tr><td><strong>\/SQLCOLLATION=<\/strong><strong><\/strong><\/td><td>Latin1_General_CI_AS<\/td><td>Collation for the rebuilt master. Must match the original collation exactly &mdash; check with: <code>SELECT SERVERPROPERTY('Collation')<\/code>.<\/td><\/tr><\/tbody><\/table><\/figure><p class=\"wp-block-paragraph\"><strong><em>Note:<\/em><\/strong><em> You should use this method only when the Installer and Backup methods fail to work.<\/em><\/p><h3 class=\"wp-block-heading\"><strong>Method 4: Repair Corrupt Master Database using Stellar Repair for MS SQL<\/strong><\/h3><p class=\"wp-block-paragraph\">If the master.mdf or mastlog.ldf file is highly damaged or corrupted, you can use <a href=\"https:\/\/www.stellarinfo.com\/sql-database-repair.php\" id=\"https:\/\/www.stellarinfo.com\/sql-database-repair.php\">Stellar Repair for MS SQL<\/a>. This software can repair corrupt SQL Server databases in any condition. It can repair and restore primary and secondary database files without any file size limitations. The Technician edition of the tool can repair data from corrupted SQL database backup (BAK) files with complete precision. The tool can restore all the objects and metadata, such as views, including the master database, without requiring a backup file.<\/p><p class=\"wp-block-paragraph\"><strong>Use Stellar Repair for MS SQL to repair database file when:<\/strong><\/p><ul class=\"wp-block-list\">\n<li>SQL Server reports the master database as suspect or corrupt.<\/li>\n\n\n\n<li>The Installer Repair fails to fix the issue.<\/li>\n\n\n\n<li>The master.mdf file is damaged at a file&#8209;level that standard SQL recovery cannot address.<\/li>\n<\/ul><p class=\"wp-block-paragraph\"><strong>Follow the below steps to repair SQL database using Stellar Repair for MS SQL:<\/strong><\/p><ul class=\"wp-block-list\">\n<li>Stop the <strong>SQL Server service<\/strong> in Configuration Manager.<\/li>\n<\/ul><figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"504\" src=\"https:\/\/www.stellarinfo.com\/blog\/wp-content\/uploads\/2023\/02\/click-stop-services-under-sqlserverservices-in-configuration-manager-1.png\" alt=\"Stop Services in Configuration Manager\" class=\"wp-image-193612 apply-gradient-on-post-images\" srcset=\"https:\/\/www.stellarinfo.com\/blog\/wp-content\/uploads\/2023\/02\/click-stop-services-under-sqlserverservices-in-configuration-manager-1.png 1024w, https:\/\/www.stellarinfo.com\/blog\/wp-content\/uploads\/2023\/02\/click-stop-services-under-sqlserverservices-in-configuration-manager-1-300x148.png 300w, https:\/\/www.stellarinfo.com\/blog\/wp-content\/uploads\/2023\/02\/click-stop-services-under-sqlserverservices-in-configuration-manager-1-768x378.png 768w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure><ul class=\"wp-block-list\">\n<li>Launch the software and browse to the location of the master database file. To know the master database location, you can use the <strong>Find<\/strong> button in the application.<\/li>\n<\/ul><figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"778\" height=\"525\" src=\"https:\/\/www.stellarinfo.com\/blog\/wp-content\/uploads\/2023\/02\/click-find-option-to-select-corrupt-file.png\" alt=\"Find option to select corrupt SQL database in Stellar Repair for MSSQL\" class=\"wp-image-193615 apply-gradient-on-post-images\" srcset=\"https:\/\/www.stellarinfo.com\/blog\/wp-content\/uploads\/2023\/02\/click-find-option-to-select-corrupt-file.png 778w, https:\/\/www.stellarinfo.com\/blog\/wp-content\/uploads\/2023\/02\/click-find-option-to-select-corrupt-file-300x202.png 300w, https:\/\/www.stellarinfo.com\/blog\/wp-content\/uploads\/2023\/02\/click-find-option-to-select-corrupt-file-768x518.png 768w\" sizes=\"auto, (max-width: 778px) 100vw, 778px\" \/><\/figure><ul class=\"wp-block-list\">\n<li>Once the application finds your master.mdf file, select it, and press the <strong>Repair<\/strong> button. You can also check the <strong>Include Deleted Records<\/strong> checkbox to recover deleted records.<\/li>\n<\/ul><figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"778\" height=\"525\" src=\"https:\/\/www.stellarinfo.com\/blog\/wp-content\/uploads\/2023\/02\/include-deleted-records-in-select-database-window.png\" alt=\"include deleted records in Select database window\" class=\"wp-image-193618 apply-gradient-on-post-images\" srcset=\"https:\/\/www.stellarinfo.com\/blog\/wp-content\/uploads\/2023\/02\/include-deleted-records-in-select-database-window.png 778w, https:\/\/www.stellarinfo.com\/blog\/wp-content\/uploads\/2023\/02\/include-deleted-records-in-select-database-window-300x202.png 300w, https:\/\/www.stellarinfo.com\/blog\/wp-content\/uploads\/2023\/02\/include-deleted-records-in-select-database-window-768x518.png 768w\" sizes=\"auto, (max-width: 778px) 100vw, 778px\" \/><\/figure><ul class=\"wp-block-list\">\n<li>Next, select the scan mode and click <strong>OK.<\/strong><\/li>\n\n\n\n<li>Preview the recovered database objects in the tree view.<\/li>\n\n\n\n<li>Click <strong>Save &gt; choose Save<\/strong> as New Database or export to CSV\/Excel\/HTML.<\/li>\n<\/ul><h2 class=\"wp-block-heading\" id=\"best-practices-for-master-database-backup-and-protection\">Best Practices for Master Database Backup and Protection<\/h2><p class=\"wp-block-paragraph\">Follow these best practices to ensure that you can recover master database quickly in case of corruption or failure:<\/p><ul class=\"wp-block-list\">\n<li>Schedule regular master backups after any significant server configuration change &mdash; logins added, linked servers created, databases registered, etc.<\/li>\n\n\n\n<li>Back up after every server-level change: The master database only needs backing up when its content changes. Automate this using SQL Server Agent.<\/li>\n\n\n\n<li>Try to keep the backup of your master database on a separate drive or network location.<\/li>\n\n\n\n<li>Document the collation value as you will need it for a rebuild. Changing the collation post-rebuild is extremely complex.<\/li>\n\n\n\n<li>Restore master database to a test instance periodically.<\/li>\n\n\n\n<li>Enable SQL Server error logs to learn about alerts before they precede master database corruption.<\/li>\n<\/ul><h2 class=\"wp-block-heading\" id=\"conclusion\"><strong>Conclusion<\/strong><\/h2><p class=\"wp-block-paragraph\">If your SQL Server service fails due to corruption in master database, recovering it requires specialized approaches. In this guide, we explored four methods to address corruption in Master database. You can use SQL Server Installer, or restore from Backup via SQLCMD. If no backup is available, then you can use the command-line method as a last resort, as it can cause data loss. To repair corrupt master.mdf files directly without any backup, use Stellar Repair for MS SQL.<\/p><h2 class=\"wp-block-heading\" id=\"faqs\">FAQs<\/h2><p class=\"wp-block-paragraph\"><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In Microsoft SQL Server, the master database is the primary system database&hellip; <a class=\"more-link\" href=\"https:\/\/www.stellarinfo.com\/blog\/how-to-rebuild-and-restore-master-database-in-sql-server\/\">Continue reading <span class=\"screen-reader-text\">How to Rebuild and Restore Master Database in SQL Server?<\/span><\/a><\/p>\n","protected":false},"author":85,"featured_media":123110,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[10],"tags":[4468],"class_list":["post-122765","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-database-recovery","tag-rebuild-and-restore-master-database","entry"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.9 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Rebuild and Restore Master Database in SQL Server<\/title>\n<meta name=\"description\" content=\"Recover a corrupt master database in SQL Server with step by step methods to repair, restore, or rebuild using backups, installer repair, setup command line, or professional SQL repair tool.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.stellarinfo.com\/blog\/how-to-rebuild-and-restore-master-database-in-sql-server\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Rebuild and Restore Master Database in SQL Server\" \/>\n<meta property=\"og:description\" content=\"Recover a corrupt master database in SQL Server with step by step methods to repair, restore, or rebuild using backups, installer repair, setup command line, or professional SQL repair tool.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.stellarinfo.com\/blog\/how-to-rebuild-and-restore-master-database-in-sql-server\/\" \/>\n<meta property=\"og:site_name\" content=\"Stellar Data Recovery Blog\" \/>\n<meta property=\"article:published_time\" content=\"2023-02-02T06:02:12+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2026-06-26T07:35:25+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.stellarinfo.com\/blog\/wp-content\/uploads\/2023\/02\/How-to-Rebuild-and-Restore-Master-Database-in-SQL-Server.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1000\" \/>\n\t<meta property=\"og:image:height\" content=\"600\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Bharat Bhushan\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Bharat Bhushan\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"9 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.stellarinfo.com\\\/blog\\\/how-to-rebuild-and-restore-master-database-in-sql-server\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.stellarinfo.com\\\/blog\\\/how-to-rebuild-and-restore-master-database-in-sql-server\\\/\"},\"author\":{\"name\":\"Bharat Bhushan\",\"@id\":\"https:\\\/\\\/www.stellarinfo.com\\\/blog\\\/#\\\/schema\\\/person\\\/c2edd14c25759638c6a69f5aececf07a\"},\"headline\":\"How to Rebuild and Restore Master Database in SQL Server?\",\"datePublished\":\"2023-02-02T06:02:12+00:00\",\"dateModified\":\"2026-06-26T07:35:25+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.stellarinfo.com\\\/blog\\\/how-to-rebuild-and-restore-master-database-in-sql-server\\\/\"},\"wordCount\":1608,\"commentCount\":0,\"image\":{\"@id\":\"https:\\\/\\\/www.stellarinfo.com\\\/blog\\\/how-to-rebuild-and-restore-master-database-in-sql-server\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.stellarinfo.com\\\/blog\\\/wp-content\\\/uploads\\\/2023\\\/02\\\/How-to-Rebuild-and-Restore-Master-Database-in-SQL-Server.jpg\",\"keywords\":[\"rebuild and restore master database\"],\"articleSection\":[\"SQL Database Repair\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.stellarinfo.com\\\/blog\\\/how-to-rebuild-and-restore-master-database-in-sql-server\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.stellarinfo.com\\\/blog\\\/how-to-rebuild-and-restore-master-database-in-sql-server\\\/\",\"url\":\"https:\\\/\\\/www.stellarinfo.com\\\/blog\\\/how-to-rebuild-and-restore-master-database-in-sql-server\\\/\",\"name\":\"Rebuild and Restore Master Database in SQL Server\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.stellarinfo.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.stellarinfo.com\\\/blog\\\/how-to-rebuild-and-restore-master-database-in-sql-server\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.stellarinfo.com\\\/blog\\\/how-to-rebuild-and-restore-master-database-in-sql-server\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.stellarinfo.com\\\/blog\\\/wp-content\\\/uploads\\\/2023\\\/02\\\/How-to-Rebuild-and-Restore-Master-Database-in-SQL-Server.jpg\",\"datePublished\":\"2023-02-02T06:02:12+00:00\",\"dateModified\":\"2026-06-26T07:35:25+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/www.stellarinfo.com\\\/blog\\\/#\\\/schema\\\/person\\\/c2edd14c25759638c6a69f5aececf07a\"},\"description\":\"Recover a corrupt master database in SQL Server with step by step methods to repair, restore, or rebuild using backups, installer repair, setup command line, or professional SQL repair tool.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.stellarinfo.com\\\/blog\\\/how-to-rebuild-and-restore-master-database-in-sql-server\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.stellarinfo.com\\\/blog\\\/how-to-rebuild-and-restore-master-database-in-sql-server\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.stellarinfo.com\\\/blog\\\/how-to-rebuild-and-restore-master-database-in-sql-server\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.stellarinfo.com\\\/blog\\\/wp-content\\\/uploads\\\/2023\\\/02\\\/How-to-Rebuild-and-Restore-Master-Database-in-SQL-Server.jpg\",\"contentUrl\":\"https:\\\/\\\/www.stellarinfo.com\\\/blog\\\/wp-content\\\/uploads\\\/2023\\\/02\\\/How-to-Rebuild-and-Restore-Master-Database-in-SQL-Server.jpg\",\"width\":1000,\"height\":600,\"caption\":\"Image of How to Rebuild and Restore Master Database in SQL Server blog thumbnail\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.stellarinfo.com\\\/blog\\\/how-to-rebuild-and-restore-master-database-in-sql-server\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.stellarinfo.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to Rebuild and Restore Master Database in SQL Server?\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.stellarinfo.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/www.stellarinfo.com\\\/blog\\\/\",\"name\":\"Stellar Data Recovery Blog\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.stellarinfo.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.stellarinfo.com\\\/blog\\\/#\\\/schema\\\/person\\\/c2edd14c25759638c6a69f5aececf07a\",\"name\":\"Bharat Bhushan\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/8371107c793354293acf244b899d7bf7f4209ee58e4305f3b195241bd426ef12?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/8371107c793354293acf244b899d7bf7f4209ee58e4305f3b195241bd426ef12?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/8371107c793354293acf244b899d7bf7f4209ee58e4305f3b195241bd426ef12?s=96&d=mm&r=g\",\"caption\":\"Bharat Bhushan\"},\"description\":\"Bharat Bhushan is an experienced technical Marketer working at Stellar Data Recovery - expertise in data care. He is skilled in Microsoft Exchange Database, MSSQL Database troubleshooting &amp; data warehousing. He is a Management Post Graduate having a strong grip in Technology &amp; certified in SAP-SD, Oracle 10g &amp; Informatica Powercenter 9.1.\",\"sameAs\":[\"https:\\\/\\\/www.linkedin.com\\\/in\\\/bharat-bhushan-311956144\\\/\"],\"url\":\"https:\\\/\\\/www.stellarinfo.com\\\/blog\\\/author\\\/bharat\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Rebuild and Restore Master Database in SQL Server","description":"Recover a corrupt master database in SQL Server with step by step methods to repair, restore, or rebuild using backups, installer repair, setup command line, or professional SQL repair tool.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.stellarinfo.com\/blog\/how-to-rebuild-and-restore-master-database-in-sql-server\/","og_locale":"en_US","og_type":"article","og_title":"Rebuild and Restore Master Database in SQL Server","og_description":"Recover a corrupt master database in SQL Server with step by step methods to repair, restore, or rebuild using backups, installer repair, setup command line, or professional SQL repair tool.","og_url":"https:\/\/www.stellarinfo.com\/blog\/how-to-rebuild-and-restore-master-database-in-sql-server\/","og_site_name":"Stellar Data Recovery Blog","article_published_time":"2023-02-02T06:02:12+00:00","article_modified_time":"2026-06-26T07:35:25+00:00","og_image":[{"width":1000,"height":600,"url":"https:\/\/www.stellarinfo.com\/blog\/wp-content\/uploads\/2023\/02\/How-to-Rebuild-and-Restore-Master-Database-in-SQL-Server.jpg","type":"image\/jpeg"}],"author":"Bharat Bhushan","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Bharat Bhushan","Est. reading time":"9 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.stellarinfo.com\/blog\/how-to-rebuild-and-restore-master-database-in-sql-server\/#article","isPartOf":{"@id":"https:\/\/www.stellarinfo.com\/blog\/how-to-rebuild-and-restore-master-database-in-sql-server\/"},"author":{"name":"Bharat Bhushan","@id":"https:\/\/www.stellarinfo.com\/blog\/#\/schema\/person\/c2edd14c25759638c6a69f5aececf07a"},"headline":"How to Rebuild and Restore Master Database in SQL Server?","datePublished":"2023-02-02T06:02:12+00:00","dateModified":"2026-06-26T07:35:25+00:00","mainEntityOfPage":{"@id":"https:\/\/www.stellarinfo.com\/blog\/how-to-rebuild-and-restore-master-database-in-sql-server\/"},"wordCount":1608,"commentCount":0,"image":{"@id":"https:\/\/www.stellarinfo.com\/blog\/how-to-rebuild-and-restore-master-database-in-sql-server\/#primaryimage"},"thumbnailUrl":"https:\/\/www.stellarinfo.com\/blog\/wp-content\/uploads\/2023\/02\/How-to-Rebuild-and-Restore-Master-Database-in-SQL-Server.jpg","keywords":["rebuild and restore master database"],"articleSection":["SQL Database Repair"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.stellarinfo.com\/blog\/how-to-rebuild-and-restore-master-database-in-sql-server\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.stellarinfo.com\/blog\/how-to-rebuild-and-restore-master-database-in-sql-server\/","url":"https:\/\/www.stellarinfo.com\/blog\/how-to-rebuild-and-restore-master-database-in-sql-server\/","name":"Rebuild and Restore Master Database in SQL Server","isPartOf":{"@id":"https:\/\/www.stellarinfo.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.stellarinfo.com\/blog\/how-to-rebuild-and-restore-master-database-in-sql-server\/#primaryimage"},"image":{"@id":"https:\/\/www.stellarinfo.com\/blog\/how-to-rebuild-and-restore-master-database-in-sql-server\/#primaryimage"},"thumbnailUrl":"https:\/\/www.stellarinfo.com\/blog\/wp-content\/uploads\/2023\/02\/How-to-Rebuild-and-Restore-Master-Database-in-SQL-Server.jpg","datePublished":"2023-02-02T06:02:12+00:00","dateModified":"2026-06-26T07:35:25+00:00","author":{"@id":"https:\/\/www.stellarinfo.com\/blog\/#\/schema\/person\/c2edd14c25759638c6a69f5aececf07a"},"description":"Recover a corrupt master database in SQL Server with step by step methods to repair, restore, or rebuild using backups, installer repair, setup command line, or professional SQL repair tool.","breadcrumb":{"@id":"https:\/\/www.stellarinfo.com\/blog\/how-to-rebuild-and-restore-master-database-in-sql-server\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.stellarinfo.com\/blog\/how-to-rebuild-and-restore-master-database-in-sql-server\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.stellarinfo.com\/blog\/how-to-rebuild-and-restore-master-database-in-sql-server\/#primaryimage","url":"https:\/\/www.stellarinfo.com\/blog\/wp-content\/uploads\/2023\/02\/How-to-Rebuild-and-Restore-Master-Database-in-SQL-Server.jpg","contentUrl":"https:\/\/www.stellarinfo.com\/blog\/wp-content\/uploads\/2023\/02\/How-to-Rebuild-and-Restore-Master-Database-in-SQL-Server.jpg","width":1000,"height":600,"caption":"Image of How to Rebuild and Restore Master Database in SQL Server blog thumbnail"},{"@type":"BreadcrumbList","@id":"https:\/\/www.stellarinfo.com\/blog\/how-to-rebuild-and-restore-master-database-in-sql-server\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.stellarinfo.com\/blog\/"},{"@type":"ListItem","position":2,"name":"How to Rebuild and Restore Master Database in SQL Server?"}]},{"@type":"WebSite","@id":"https:\/\/www.stellarinfo.com\/blog\/#website","url":"https:\/\/www.stellarinfo.com\/blog\/","name":"Stellar Data Recovery Blog","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.stellarinfo.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.stellarinfo.com\/blog\/#\/schema\/person\/c2edd14c25759638c6a69f5aececf07a","name":"Bharat Bhushan","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/8371107c793354293acf244b899d7bf7f4209ee58e4305f3b195241bd426ef12?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/8371107c793354293acf244b899d7bf7f4209ee58e4305f3b195241bd426ef12?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/8371107c793354293acf244b899d7bf7f4209ee58e4305f3b195241bd426ef12?s=96&d=mm&r=g","caption":"Bharat Bhushan"},"description":"Bharat Bhushan is an experienced technical Marketer working at Stellar Data Recovery - expertise in data care. He is skilled in Microsoft Exchange Database, MSSQL Database troubleshooting &amp; data warehousing. He is a Management Post Graduate having a strong grip in Technology &amp; certified in SAP-SD, Oracle 10g &amp; Informatica Powercenter 9.1.","sameAs":["https:\/\/www.linkedin.com\/in\/bharat-bhushan-311956144\/"],"url":"https:\/\/www.stellarinfo.com\/blog\/author\/bharat\/"}]}},"_links":{"self":[{"href":"https:\/\/www.stellarinfo.com\/blog\/wp-json\/wp\/v2\/posts\/122765","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.stellarinfo.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.stellarinfo.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.stellarinfo.com\/blog\/wp-json\/wp\/v2\/users\/85"}],"replies":[{"embeddable":true,"href":"https:\/\/www.stellarinfo.com\/blog\/wp-json\/wp\/v2\/comments?post=122765"}],"version-history":[{"count":25,"href":"https:\/\/www.stellarinfo.com\/blog\/wp-json\/wp\/v2\/posts\/122765\/revisions"}],"predecessor-version":[{"id":193729,"href":"https:\/\/www.stellarinfo.com\/blog\/wp-json\/wp\/v2\/posts\/122765\/revisions\/193729"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.stellarinfo.com\/blog\/wp-json\/wp\/v2\/media\/123110"}],"wp:attachment":[{"href":"https:\/\/www.stellarinfo.com\/blog\/wp-json\/wp\/v2\/media?parent=122765"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.stellarinfo.com\/blog\/wp-json\/wp\/v2\/categories?post=122765"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.stellarinfo.com\/blog\/wp-json\/wp\/v2\/tags?post=122765"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}