Start SQL Server in Single-User Mode
Under certain circumstances, you may have to start an instance of SQL Server in single-user mode by using the startup option -m. For example, you may want to change server configuration options or recover a damaged master database or other system database. Both actions require starting an instance of SQL Server in single-user mode.
Starting SQL Server in single-user mode enables any member of the computer's local Administrators group to connect to the instance of SQL Server as a member of the sysadmin fixed server role. For more information, see Connect to SQL Server When System Administrators Are Locked Out.
When you start an instance of SQL Server in single-user mode, note the following:
Only one user can connect to the server.
The CHECKPOINT process is not executed. By default, it is executed automatically at startup.
Stop the SQL Server Agent service before connecting to an instance of SQL Server in single-user mode; otherwise, the SQL Server Agent service uses the connection, thereby blocking it.
When you start an instance of SQL Server in single-user mode, SQL Server Management Studio can connect to SQL Server. Object Explorer in Management Studio might fail because it requires more than one connection for some operations. To manage SQL Server in single-user mode, execute Transact-SQL statements by connecting only through the Query Editor in Management Studio, or use the sqlcmd utility.
When you use the -m option with SQLCMD or Management Studio, you can limit the connections to a specified client application.
On Linux, SQLCMD must be capitalized as shown.
For example, -m"SQLCMD" limits connections to a single connection and that connection must identify itself as the SQLCMD client program. Use this option when you are starting SQL Server in single-user mode and an unknown client application is taking the only available connection. To connect through the Query Editor in Management Studio, use -m"Microsoft SQL Server Management Studio - Query".
Do not use this option as a security feature. The client application provides the client application name, and can provide a false name as part of the connection string.
Note for Clustered installations
For SQL Server installation in a clustered environment, when SQL Server is started in single user mode, the cluster resource dll uses up the available connection thereby blocking any other connections to the server. When SQL Server is in this state, if you try to bring SQL Server Agent resource online, it may fail over the SQL resource to a different node if the resource is configured to affect the group.
To get around the problem use the following procedure:
Remove the –m startup parameter from the SQL Server advanced Properties.
Take the SQL Server resource offline.
From the current owner node of this group, issue the following command from the command prompt:
net start MSSQLSERVER /m.
Verify from the cluster administrator or failover cluster management console that the SQL Server resource is still offline.
Connect to the SQL Server now using the following command and do the necessary operation: SQLCMD -E -S<servername>.
Once the operation is complete, close the command prompt and bring back the SQL and other resources online through cluster administrator.
Start, Stop, or Pause the SQL Server Agent Service
Diagnostic Connection for Database Administrators
Database Engine Service Startup Options