A colleague feedback SQL failed to log in normally, was previously logged in through Windows Integrated authentication (SA password has been forgotten), today changed the server's machine name, and now no matter how to log in.
If Windows Integrated authentication is used for SQL login, the login box will display the login in the format "machine name \ Current system user name" and the login name and password are grayed out and not allowed to be entered by the user.
Knowing that a colleague has just modified the server's machine name, the "new machine name \ Current system user name" is displayed in the SQL login box. To know that Windows Integrated authentication can log on because the user name has been included in the SQL login name, the original user name in SQL installation has been recorded in SQL, if the machine name changed, "New machine name \ Current system user name" will definitely not log on properly.
Online to see someone said can use Osql–s instancename–e (input in the Command Line window) to log in and then go to modify the sa password, after trying to find that is a talk, because the premise is to use the Windows integrated identity to be able to log in.
Later on Microsoft's official web page to see a document, as long as the SQL in the startup parameters to add a "-m" option (Remember to Add a semicolon before-m), Then you need to restart the SQL service again with SQL Management Studio windows Integrated authentication login is available.
-M indicates single-user login. The attentive reader may question: Just add-m, but finally use Windows Integrated authentication, what is the difference between theory and the previous use of Sqlos–s instancename–e?
This is a very professional question. I did not understand it at that time, it was a bit strange, but the result is this, there must be a reason. It was later found on Microsoft's official website.
Start the instance of SQL Server in Single-user mode by using either the- m or- f options. Any member of the computer's local Administrators group can then connect to the instance of SQL Server as a member of the sysadmin fixed server role.
Probably means that when you add the- m or -F parameter to the SQL startup Parameters , any user of the local Administrators group of the computer can Log in to SQL as the sysadmin . believe that the reader sees this place to understand. This is not actually going to verify that the logged-on user is in SQL presence, just check whether the user is a user in the administrative group of the local computer.
OK, believe that the back will not be too cumbersome, just remind the reader: after modifying the sa Password Remember to add the original SQL startup parameters of- m Delete, and then restart the SQL service.