Skip to content

Commit 3b7a114

Browse files
committed
another refresh
1 parent 74e4d40 commit 3b7a114

1 file changed

Lines changed: 11 additions & 11 deletions

File tree

docs/database-engine/configure-windows/connect-to-sql-server-when-system-administrators-are-locked-out.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ title: "Connect to SQL Server when system administrators are locked out"
33
description: Learn how to regain access to SQL Server as a system administrator if you've been mistakenly locked out.
44
author: rwestMSFT
55
ms.author: randolphwest
6-
ms.date: 07/14/2022
6+
ms.date: 08/21/2023
77
ms.service: sql
88
ms.subservice: configuration
99
ms.topic: conceptual
@@ -25,15 +25,15 @@ This article describes how you can regain access to the [!INCLUDE[ssDEnoversion]
2525

2626
- The logins that are members of the sysadmin fixed server role are for individuals who have left the company or who aren't available.
2727

28-
- The sa account is disabled or no one knows the password.
28+
- The `sa` account is disabled or no one knows the password.
2929

3030
## Resolution
3131

3232
In order to resolve your access issue, we recommend that you start the instance of [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)] in single-user mode. This mode prevents other connections from occurring while you try to regain access. From here, you can connect to your instance of SQL Server and add your login to the **sysadmin** server role. Detailed steps for this solution are provided in the [step-by-step-instructions](#step-by-step-instructions) section.
3333

3434
You can start an instance of [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)] in single-user mode with either the `-m` or `-f` options from the command line. Any member of the computer's local Administrators group can then connect to the instance of [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)] as a member of the **sysadmin** fixed server role.
3535

36-
When you start the instance in single-user mode, first stop the [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)] Agent service. Otherwise, [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)] Agent might connect first, taking the only available connection to the server and blocking you from logging in.
36+
When you start the instance in single-user mode, stop the [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)] Agent service. Otherwise, [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)] Agent might connect first, taking the only available connection to the server and blocking you from logging in.
3737

3838
It's also possible for an unknown client application to take the only available connection before you're able to sign in. In order to prevent this from happening, you can use the `-m` option followed by an application name to limit connections to a single connection from the specified application. For example, starting [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)] with `-mSQLCMD` limits connections to a single connection that identifies itself as the **sqlcmd** client program. To connect through the Query Editor in [!INCLUDE[ssManStudio](../../includes/ssmanstudio-md.md)], use `-m"Microsoft SQL Server Management Studio - Query"`.
3939

@@ -55,10 +55,10 @@ For step-by-step instructions about how to start [!INCLUDE[ssNoVersion](../../in
5555

5656
### Use PowerShell
5757

58-
#### Option 1: Run the steps directly in an executable notebook via Azure Data Studio
58+
#### Option 1: Run the steps directly in an executable notebook using Azure Data Studio
5959

6060
> [!NOTE]
61-
> Before attempting to open this notebook, check that Azure Data Studio is installed on your local machine. To install, go to [Learn how to install Azure Data Studio](../../azure-data-studio/download-azure-data-studio.md).
61+
> Before attempting to open this notebook, check that Azure Data Studio is installed on your local machine. To install Azure Data Studio, see [Learn how to install Azure Data Studio](../../azure-data-studio/download-azure-data-studio.md).
6262
6363
> [!div class="nextstepaction"]
6464
> [Open Notebook in Azure Data Studio](azuredatastudio://microsoft.notebook/open?url=https://raw.githubusercontent.com/microsoft/mssql-support/master/sample-scripts/DOCs-to-Notebooks/T-shooting-SQL-SystemAdmins-Locked-out.ipynb)
@@ -108,7 +108,7 @@ For step-by-step instructions about how to start [!INCLUDE[ssNoVersion](../../in
108108
> `Sqlcmd: Error: Microsoft ODBC Driver X for SQL Server : Login failed for user 'CONTOSO\BobD'. Reason: Server is in single user mode. Only one administrator can connect at this time..`
109109
110110
1. **Mixed Mode (optional):** If your SQL Server is running in mixed authentication mode, you can also:
111-
1. Grant the Sysadmin role membership to a SQL login. Execute code such as the following to create a new SQL Server authentication login that is a member of the sysadmin fixed server role. Replace "?j8:z$G=JE9" with a strong password of your choice.
111+
1. Grant the **sysadmin** role membership to a SQL login. Execute code such as the following to create a new SQL Server authentication login that is a member of the **sysadmin** fixed server role. Replace `?j8:z$G=JE9` with a strong password of your choice.
112112

113113
If you have a default instance, use the name of the server.
114114

@@ -117,7 +117,7 @@ For step-by-step instructions about how to start [!INCLUDE[ssNoVersion](../../in
117117
sqlcmd.exe -E -S $sql_server_instance -Q "CREATE LOGIN TempLogin WITH PASSWORD = '$strong_password'; ALTER SERVER ROLE sysadmin ADD MEMBER TempLogin; "
118118
```
119119
120-
1. Also, if your SQL Server is running in mixed authentication mode and you want to reset the password of an enabled **sa** account. Change the password of the sa account with the following syntax. Be sure to replace "j8:zG=J?E9" with a strong password of your choice:
120+
1. Also, if your SQL Server is running in mixed authentication mode and you want to reset the password of an enabled **sa** account. Change the password of the sa account with the following syntax. Be sure to replace `j8:zG=J?E9` with a strong password of your choice:
121121
122122
If you have a default instance, use the name of the server.
123123
@@ -151,17 +151,17 @@ Perform these instructions while logged in to Windows as a member of the local a
151151

152152
1. On the **Startup Parameters** tab, in the **Specify a startup parameter** box, type `-m` and then select **Add**. (That's a dash then lower case letter m.)
153153

154-
For some earlier versions of [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)] there is no **Startup Parameters** tab. In that case, on the **Advanced** tab, double-click **Startup Parameters**. The parameters open up in a small window. Be careful not to change any of the existing parameters. At the very end, add a new parameter `;-m` and then select **OK**. (That's a semi-colon then a dash then lower case letter m.)
154+
For some earlier versions of [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)], there's no **Startup Parameters** tab. In that case, on the **Advanced** tab, double-click **Startup Parameters**. The parameters open up in a small window. Be careful not to change any of the existing parameters. At the very end, add a new parameter `;-m` and then select **OK**. (That's a semi-colon then a dash then lower case letter m.)
155155

156156
1. Select **OK**, and after the message to restart, right-click your server name, and then select **Restart**.
157157

158158
1. After [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)] has restarted, your server will be in single-user mode. Make sure that [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)] Agent isn't running. If started, it will take your only connection.
159159

160-
1. From the Windows Start menu, right-click the icon for [!INCLUDE[ssManStudio](../../includes/ssmanstudio-md.md)] and select **Run as administrator**. This will pass your administrator credentials to SSMS.
160+
1. From the Windows Start menu, right-click the icon for [!INCLUDE[ssManStudio](../../includes/ssmanstudio-md.md)] and select **Run as administrator**. This passes your administrator credentials to SSMS.
161161

162162
For earlier versions of Windows, the **Run as administrator** option appears as a submenu.
163163

164-
In some configurations, SSMS will attempt to make several connections. Multiple connections will fail because [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)] is in single-user mode. Based on your scenario, perform one of the following actions.
164+
In some configurations, SSMS attempts to make several connections. Multiple connections will fail because [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)] is in single-user mode. Based on your scenario, perform one of the following actions.
165165

166166
1. Connect with Object Explorer using Windows Authentication, which includes your Administrator credentials. Expand **Security**, expand **Logins**, and double-click your own login. On the **Server Roles** page, select **sysadmin**, and then select **OK**.
167167

@@ -199,7 +199,7 @@ Perform these instructions while logged in to Windows as a member of the local a
199199

200200
1. On the **Startup Parameters** tab, in the **Existing parameters** box, select `-m` and then select **Remove**.
201201

202-
For some earlier versions of [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)] there is no **Startup Parameters** tab. In that case, on the **Advanced** tab, double-click **Startup Parameters**. The parameters open up in a small window. Remove the `;-m` that you added earlier, and then select **OK**.
202+
For some earlier versions of [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)], there's no **Startup Parameters** tab. In that case, on the **Advanced** tab, double-click **Startup Parameters**. The parameters open up in a small window. Remove the `;-m` that you added earlier, and then select **OK**.
203203
204204
1. Right-click your server name, and then select **Restart**. Make sure to start [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)] Agent again if you stopped it before starting [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)] in single-user mode.
205205

0 commit comments

Comments
 (0)