debugsqlMinor
Cannot use SQLCMD
Viewed 0 times
cannotusesqlcmd
Problem
I have started SQL Server in single user mode like this:
When I try to connect to it with
The user I am logged onto the server as is a domain administrator.
Before I tried this, the user I am logged on as had nothing to do with this SQL server. (I am in fact, trying to create a new SA as we don't know what the current password is)
Edit
It seems that even if I do:
I am still getting the above error. I am not sure if there are other
c:\....\sqlservr -mWhen I try to connect to it with
SQLCMD -E, I get the following error:Msg 18461, Level 14, State 1, Server SERVERNAME, Line 1
Login failed to user 'USER\Name'. Reason: Server is in single user mode. Only one administrator can connect at this time.The user I am logged onto the server as is a domain administrator.
Before I tried this, the user I am logged on as had nothing to do with this SQL server. (I am in fact, trying to create a new SA as we don't know what the current password is)
Edit
It seems that even if I do:
c:\....\sqlservr -m"sqlcmd"I am still getting the above error. I am not sure if there are other
SQLCMD calls happening from elsewhere.Solution
This case is explicitly called out in Connect to SQL Server When System Administrators Are Locked Out:
When you start an instance of SQL Server in single-user mode, first stop the SQL Server Agent service. Otherwise, SQL Server Agent might connect first and prevent you from connecting as a second user.
When you use the -m option with sqlcmd or SQL Server Management Studio, you can limit the connections to a specified client application. For example,
When you start an instance of SQL Server in single-user mode, first stop the SQL Server Agent service. Otherwise, SQL Server Agent might connect first and prevent you from connecting as a second user.
When you use the -m option with sqlcmd or SQL Server Management Studio, you can limit the connections to a specified client application. 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".Context
StackExchange Database Administrators Q#50797, answer score: 8
Revisions (0)
No revisions yet.