You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This article explains how to restore the `master` database from a full database backup.
18
+
This article explains how to restore the `master` database from a full database backup.
19
+
20
+
> [!WARNING]
21
+
> In the event of disaster recovery, the instance where the `master` database is being restored to should be as close to an exact match to the original as possible. At a minimum, this recovery instance should be the same version, edition, and patch level, and it should have the same selection of features and the same external configuration (hostname, cluster membership, and so on) as the original instance. Doing otherwise can result in undefined SQL Server instance behavior, with inconsistent feature support, and isn't guaranteed to be viable.
22
+
23
+
## Restore the `master` database
24
+
25
+
1. Start the server instance in single-user mode.
26
+
27
+
You can start SQL Server by either using the `-m` or `-f` startup parameters. For more information about startup parameters, see [Database Engine Service startup options](../../database-engine/configure-windows/database-engine-service-startup-options.md).
18
28
19
-
> [!WARNING]
20
-
> In the event of disaster recovery, the instance where the `master` database is being restored to should be as close to an exact match to the original as possible. At a minimum, this recovery instance should be the same version, edition, and patch level, and it should have the same selection of features and the same external configuration (hostname, cluster membership, and so on) as the original instance. Doing otherwise might result in undefined SQL Server instance behavior, with inconsistent feature support, and is not guaranteed to be viable.
21
-
22
-
### To restore the `master` database
23
-
24
-
1. Start the server instance in single-user mode.
25
-
26
-
You can start SQL Server by either using the `-m` or `-f` startup parameters. For more information about startup parameters, see [Database Engine Service Startup Options](../../database-engine/configure-windows/database-engine-service-startup-options.md).
27
-
28
29
From a command prompt, run the following commands, and make sure you replace `MSSQLXX.instance` with the appropriate folder name:
29
-
30
+
30
31
```console
31
32
cd C:\Program Files\Microsoft SQL Server\MSSQLXX.instance\MSSQL\Binn
32
33
sqlservr -c -f -s <instance> -mSQLCMD
@@ -35,52 +36,51 @@ helpviewer_keywords:
35
36
- The `-mSQLCMD` parameter ensures that only **sqlcmd** can connect to SQL Server.
36
37
- For a default instance name, use `-s MSSQLSERVER`
37
38
-`-c` starts SQL Server as an application to bypass Service Control Manager to shorten startup time
38
-
39
+
39
40
If the SQL Server instance can't start due to a damaged `master` database, you must rebuild the system databases first. For more information, see [Rebuild system databases](../databases/rebuild-system-databases.md).
40
41
41
-
1. Connect to SQL Server using SQLCMD from another Command Prompt window
42
+
1. Connect to SQL Server using **sqlcmd** from another command prompt window:
42
43
43
44
```console
44
-
SQLCMD -S <instance> -E -d master
45
+
sqlcmd -S <instance> -E -d master
46
+
```
47
+
48
+
1. To restore a full database backup of `master`, use the following [RESTORE Statements](../../t-sql/statements/restore-statements-transact-sql.md)[!INCLUDE [tsql](../../includes/tsql-md.md)] statement:
49
+
50
+
```sql
51
+
RESTORE DATABASE master FROM<backup_device> WITH REPLACE;
45
52
```
46
53
47
-
1. To restore a full database backup of **master**, use the following [RESTORE DATABASE](../../t-sql/statements/restore-statements-transact-sql.md)[!INCLUDE[tsql](../../includes/tsql-md.md)] statement:
48
-
49
-
```sql
50
-
RESTORE DATABASE master FROM<backup_device> WITH REPLACE
51
-
```
52
-
53
-
The REPLACE option instructs [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)] to restore the specified database even when a database of the same name already exists. The existing database, if any, is deleted. In single-user mode, we recommend that you enter the RESTORE DATABASE statement in the [sqlcmd utility](../../tools/sqlcmd/sqlcmd-utility.md). For more information, see [Use the sqlcmd Utility](../../tools/sqlcmd/sqlcmd-use-utility.md).
54
-
55
-
> [!IMPORTANT]
56
-
> After **master** is restored, the instance of [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)] shuts down and terminates the **sqlcmd** process. Before you restart the server instance, remove the single-user startup parameter. For more information, see [Configure Server Startup Options (SQL Server Configuration Manager)](../../database-engine/configure-windows/scm-services-configure-server-startup-options.md).
54
+
The `REPLACE` option instructs [!INCLUDE [ssNoVersion](../../includes/ssnoversion-md.md)] to restore the specified database even when a database of the same name already exists. The existing database, if any, is deleted. In single-user mode, we recommend that you enter the `RESTORE DATABASE` statement in the [sqlcmd utility](../../tools/sqlcmd/sqlcmd-utility.md). For more information, see [Use sqlcmd](../../tools/sqlcmd/sqlcmd-use-utility.md).
55
+
56
+
> [!IMPORTANT]
57
+
> After `master` is restored, the instance of [!INCLUDE [ssNoVersion](../../includes/ssnoversion-md.md)] shuts down and terminates the `sqlcmd` process. Before you restart the server instance, remove the single-user startup parameter. For more information, see [SQL Server Configuration Manager: Configure server startup options](../../database-engine/configure-windows/scm-services-configure-server-startup-options.md).
58
+
59
+
1. Restart the server instance normally as a service, without using any startup parameters.
57
60
61
+
1. Continue other recovery steps such as restoring other databases, attaching databases, and correcting user mismatches.
58
62
59
-
1. Restart the server instance normally as a service, without using any startup parameters.
60
-
1. Continue other recovery steps such as restoring other databases, attaching databases, and correcting user mismatches.
61
-
62
-
## Example
63
+
## Examples
63
64
64
-
The following example restores the `master` database on the default server instance. The example assumes that the server instance is already running in single-user mode. The example starts `sqlcmd`and executes a `RESTORE DATABASE` statement that restores a full database backup of `master`from a disk device: `Z:\SQLServerBackups\master.bak`.
65
-
66
-
> [!NOTE]
67
-
> For a named instance, the **sqlcmd** command must specify the **-S**_\<ComputerName>_\\*\<InstanceName>* option.
65
+
The following example restores the `master` database on the default server instance. The example assumes that the server instance is already running in single-user mode. The example starts **sqlcmd** and executes a `RESTORE DATABASE` statement that restores a full database backup of `master` from a disk device: `Z:\SQLServerBackups\master.bak`.
66
+
67
+
For a named instance, the **sqlcmd** command must specify the `-S<computer-name>\<instance-name>` option.
68
68
69
69
```console
70
-
C:\> sqlcmd
71
-
1> RESTORE DATABASE master FROM DISK = 'Z:\SQLServerBackups\master.bak' WITH REPLACE;
[Rebuild System Databases](../../relational-databases/databases/rebuild-system-databases.md)
82
-
[Database Engine Service Startup Options](../../database-engine/configure-windows/database-engine-service-startup-options.md)
83
-
[SQL Server Configuration Manager](../../relational-databases/sql-server-configuration-manager.md)
84
-
[Back UpandRestore of System Databases (SQL Server)](../../relational-databases/backup-restore/back-up-and-restore-of-system-databases-sql-server.md)
0 commit comments