MS SQL Server 2008 中未进行 SQL 身份验证

MS SQL Server 2008 中未进行 SQL 身份验证

当我尝试使用 SQL Server Management Studio 中的 Windows 身份验证连接到在本地主机上运行的 SQL Server 时,我能够连接,但当我尝试使用 SQL 身份验证连接时,它显示登录失败,尽管我知道数据库中存在具有密码的用户。这是错误日志 -

            ===================================

            Cannot connect to localhost.

            ===================================

            Login failed for user 'admin'. (.Net SqlClient Data Provider)

            ------------------------------
            For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&EvtSrc=MSSQLServer&EvtID=18456&LinkId=20476

            ------------------------------
            Server Name: localhost
            Error Number: 18456
            Severity: 14
            State: 1
            Line Number: 65536


            ------------------------------
            Program Location:

               at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection)
               at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj)
               at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)
               at System.Data.SqlClient.SqlInternalConnectionTds.CompleteLogin(Boolean enlistOK)
               at System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, Boolean ignoreSniOpenTimeout, Int64 timerExpire, SqlConnection owningObject)
               at System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(String host, String newPassword, Boolean redirectedUserInstance, SqlConnection owningObject, SqlConnectionString connectionOptions, Int64 timerStart)
               at System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(SqlConnection owningObject, SqlConnectionString connectionOptions, String newPassword, Boolean redirectedUserInstance)
               at System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, Object providerInfo, String newPassword, SqlConnection owningObject, Boolean redirectedUserInstance)
               at System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection)
               at System.Data.ProviderBase.DbConnectionFactory.CreateNonPooledConnection(DbConnection owningConnection, DbConnectionPoolGroup poolGroup)
               at System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection)
               at System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory)
               at System.Data.SqlClient.SqlConnection.Open()
               at Microsoft.SqlServer.Management.UI.VSIntegration.ObjectExplorer.ObjectExplorer.ValidateConnection(UIConnectionInfo ci, IServerType server)
               at Microsoft.SqlServer.Management.UI.ConnectionDlg.Connector.ConnectionThreadUser()

答案1

确保登录已在服务器级别并且登录名已分配给用户在数据库中。还要确保混合模式身份验证已启用。

答案2

不要使用 localhost,使用服务器名称。防火墙怎么办?

相关内容