正确设置MSSQL 2012的sa帐户.无法登录



按照许多教程中的建议,我在SQL Server 2012上进行了以下设置:

  • 我将服务器身份验证设置为"SQL server和Windows身份验证模式"
  • 我为SA用户设置了一个带有强制密码策略的强密码,默认数据库为"master"
  • 我已授予SA用户连接到数据库引擎的权限,并且启用了他的登录

然而,当我尝试登录到"localhost"时通过SQL Server身份验证。

它失败了:

Cannot connect to (local).
------------------------------
Login failed for user 'sa'. (Microsoft SQL Server, Error: 18456)

我登录的唯一可能方式仍然是Windows身份验证。

我的实例名为MSSQLSERVER。localhost\MSSQLSERVER不可访问。

可能有多种原因。请检查您的错误日志并查找错误状态。根据状态,错误可能为-

State Description
1     Error information is not available. This state usually means you do not have permission to receive the error details. Contact your SQL Server administrator for more information.
2     User ID is not valid.
5     User ID is not valid.
6     An attempt was made to use a Windows login name with SQL Server Authentication.
7     Login is disabled, and the password is incorrect.
8     The password is incorrect.
9     Password is not valid.
11    Login is valid, but server access failed. One possible cause of this error is when the Windows user has access to SQL Server as a member of the local administrators group, but Windows is not providing administrator credentials. To connect, start the connecting program using the Run as administrator option, and then add the Windows user to SQL Server as a specific login.
12    Login is valid login, but server access failed.
18    Password must be changed.

有关详细信息-MSDN

最新更新