SQL Server login problem

I wanted to use the SQLServer Express I installed before, but I found that I couldn't log in. This inability to log in refers to the sa user. Because I want to access the database in the program, the user name and password must be used.

sqlcmd -Usa -Pxxx
Msg 18456, Level 14, State 1, Server FRED\SQLEXPRESS, Line 1 Login failed for
user 'sa'. However, you can access sqlcmd

without a username and password 1> View the log C:\Program Files\Microsoft SQL Server\MSSQL10.SQLEXPRESS\MSSQL\Log\ERRORLOG and found 2016-04-09 11:25:03.14 Login error: 18456, serious Sex: 14, Status: 58. 2016-04-09 11:25:03.14 Login failed for user 'sa'. Reason: Attempt to login using SQL authentication failed. The server is configured to use Windows authentication only. [Client: 192.168.1.107] Then I searched the Internet and found out that SQL Server has two login methods: Windows account method and SQL Server and Windows mixed login. The Windows account method will use the current Windows login account as the basis to access SQL Server by default when logging in, without entering a user name and password. The second hybrid method will use the specified account to log in. Including sa.
















Most of the methods mentioned on the Internet are to use the first login through the SQLServer client, and then you can set the login method of the database. But I found that I didn't follow the client and can't modify it through the interface. Finally found the LoginMode key that can be modified in the registry:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server\MSSQL10.SQLEXPRESS\MSSQLServer , change its value from 1 to 2 (in hexadecimal) . (This registry path may be related to the specific environment, not necessarily the same) Note that the SQLServer service must be stopped first. After modification, restart. However, after doing this, I log in again with the sa account and still get an error. View Log 2016-04-09 11:07:56.89 Login Error: 18456, Severity: 14, Status: 7. 2016-04-09 11:07:56.89 Login Login failed for user 'sa'. Reason: Error evaluating password. [Client: 192.168.1.107] This "evaluation password error", after some searching, it is guessed that the password may have expired. So I logged in in the first way, and then changed the password of sa. ALTER LOGIN sa WITH PASSWORD='*********' go ALTER LOGIN sa ENABLE go and then log in with the new password, successful. By the way, let's talk about the SQLServer service:






















Open the "SQLServer Configuration Manager":
the following port can be configured to start SQLServer



Note that the login identity of the properties of the SQLServer service selects Network Service







Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326988967&siteId=291194637