用户登录失败。用户未与受信任的SQL Server连接关联 - SQL Server 2005

时间:2022-01-13 01:06:35

I'm running the following scripts to

我正在运行以下脚本

  1. Create a database
  2. 创建一个数据库

  3. Create Login
  4. Assign Login to the database
  5. 分配登录到数据库

  6. Assign database roles
  7. 分配数据库角色

  8. Create tables in the database
  9. 在数据库中创建表

The scripts are -

脚本是 -

if not exists (
select *
from master.dbo.sysdatabases
where name = 'TESTDB')
create database TESTDB
GO

if not exists(select * from master.dbo.syslogins where name = 'testuser')
EXEC [TESTDB].dbo.sp_addlogin @loginame = N'testuser', @passwd = 'test@2010', @defdb = N'TESTDB', @deflanguage = N'us_english'
GO

USE [TESTDB]
GO
/****** Object:  User [MPS]    Script Date: 01/22/2011 17:53:17 ******/
GO              
if exists(select * from master.dbo.syslogins where name = 'testuser' AND dbname = 'TESTDB')
EXEC dbo.sp_grantdbaccess @loginame = N'testuser'
GO

USE [TESTDB]

EXEC sp_addrolemember 'db_owner', 'testuser'
EXEC sp_addrolemember 'db_accessadmin', 'testuser'
EXEC sp_addrolemember 'db_securityadmin', 'testuser'

USE [TESTDB]

GO
/****** Object:  Table [dbo].[tblJobs]    Script Date: 01/22/2011 17:04:05 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF OBJECT_ID('tblJobs','U') is null
BEGIN
CREATE TABLE [dbo].[tblJobs](
    [ID] [int] IDENTITY(1,1) NOT NULL,
    [JobTitle] [nvarchar](4000) NOT NULL
) ON [PRIMARY]
END

Everything is getting created without any issue. But when I try to login using testuser I get the error -

一切都在没有任何问题的情况下创建。但是当我尝试使用testuser登录时,我收到错误 -

Login failed for user 'testuser'. The user is not associated with a trusted SQL server connection.

用户'testuser'登录失败。用户未与受信任的SQL Server连接关联。

Any ideas why?

有什么想法吗?

1 个解决方案

#1


3  

It might be that your server is not configured to use mixed mode authentication.

可能是您的服务器未配置为使用混合模式身份验证。

Go to server-properties and select SQL Server and Windows Authentication mode.

转到服务器属性,然后选择SQL Server和Windows身份验证模式。

用户登录失败。用户未与受信任的SQL Server连接关联 -  SQL Server 2005

#1


3  

It might be that your server is not configured to use mixed mode authentication.

可能是您的服务器未配置为使用混合模式身份验证。

Go to server-properties and select SQL Server and Windows Authentication mode.

转到服务器属性,然后选择SQL Server和Windows身份验证模式。

用户登录失败。用户未与受信任的SQL Server连接关联 -  SQL Server 2005