问题
I am getting error 18456 from SQL Server Management Studio when I try to connect Windows Authentication or SQL Server Authentication as in the pictures below.
Windows Authentication
SQL Server Authentication
I want to implement the solution in this link: Login to Microsoft SQL Server Error: 18456 but I can't start the engine in no way. Also, I don't know my password for SQL Server Authentication.
What can I do?
回答1:
I have seen this problem very often with SQL Server 2012 and later versions (usually with new installations) the reason is SQL Server 2012 and later version do not give window Administrators automatically the admin rights in SQL Server.
This will leave you with no access to the SQL Server at all, in this case I use the following approach:
Run SQL Server configuration Manager.
Location for SQL Server configuration Manager:
SQL Server 2016 C:\Windows\SysWOW64\SQLServerManager13.msc SQL Server 2014 C:\Windows\SysWOW64\SQLServerManager12.msc SQL Server 2012 C:\Windows\SysWOW64\SQLServerManager11.msc SQL Server 2008 C:\Windows\SysWOW64\SQLServerManager10.msc
Right-Click
the SQL Server Service and go toProperties
.- Go to
Startup Parameters
tab and add-m
parameter there. This will cause the SQL-Server to run in Single-User mode. Restart
the SQL Server service, make sure the SQL Server agent doesn't start, if it does start it may obtain the single available connection to the SQL Server.- Once the SQL Server Service has restarted successfully, Right-Click SSMS and
Run as Administrator
. - At this point SQL Server would let you connect to SQL Server as Administrator, add your domain account to SQL Server assign
SysAdmin
role. - Close the Management Studio, go back to the SQL Server configuration Manager remove
-m
from the startup parameters. Restart the SQL Server service and tadaaa.
Also do not do this on a server that is being used by others.
回答2:
One option is to install a new instance of SQL Server and attach any databases to the new instance, but this can be tricky for a variety of reasons, especially if you do not have a recent backup of the master
database.
Therefore, I'd suggest following the advice given by Microsoft here and start the instance in single-user mode, which will then allow any local administrator on the machine where the instance is installed to gain access and correct the authentication issues (resetting passwords etc.).
Of course, this presumes that you have access to a administrator account on the machine, which hopefully you do.
回答3:
Similar issue I faced and the solution mentioned on this post worked for me : https://stackoverflow.com/a/23395581/4409488
What it basically says is that you have to change default login mode which is set to Windows authentication only to SQL Server and Windows Authentication mode.
Right click on the server => SelectProperties => Security page => Server authentication => Select SQL Server and Windows Authentication mode radio button
Restart the SQL server from Services. And you should be good to go.
来源:https://stackoverflow.com/questions/41386538/microsoft-sql-server-error-18456