如何在 SQL Server 2012 中创建可以在连接字符串中使用的新用户? [英] How do I create a new user in SQL Server 2012 that I can use in a connection string?

查看:20
本文介绍了如何在 SQL Server 2012 中创建可以在连接字符串中使用的新用户?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不确定这是 SO 还是 SU 问题.

I wasn't sure if this was a SO or SU question.

我刚刚安装了 SQL Server 2012.

I have freshly installed SQL Server 2012.

我已经创建了一个数据库.

I have created a database.

我有一个 Visual Studio 2012 项目,我想使用 Web 配置中的连接字符串连接到数据库.

I have a visual studio 2012 project, and I want to connect to the database using a connection string in my web config.

由于我只有两个帐户(sa 和我的 Windows 帐户),我想创建一个只能访问这个数据库的新用户.

Since I only have two accounts (sa and my windows account) I want to create a new user that will only have access to this one database.

Google 说,在 SSMS 中,展开数据库,右键单击安全"并转到新建用户".

Google says, in SSMS, expand the database, right click Security and go to New User.

但是,当我这样做并尝试创建用户时,我选择了具有登录名的 SQL 用户,输入用户名和登录名,并得到错误:

However, when I do this and try to create a user, I choose SQL user with login, enter a username and login name, and get the error:

'news_login' 不是有效的登录名或您没有权限

'news_login' is not a valid login or you do not have permission

我尝试过以sa"身份登录 SSMS,以我的 Windows 帐户登录,并以管理员权限运行 SSMS.我尝试了几个不同的用户名,但都无济于事.

I've tried by logging into SSMS as 'sa', logging in as my windows account, and running SSMS with administrator permissions. I've tried a few different usernames, and to no avail.

我注意到没有密码框,所以我担心我做错了.有什么建议吗?

I notice there is no password box, so I fear I am doing it all wrong. Any suggestions?

推荐答案

在将用户添加到数据库之前,先将用户添加到服务器——在服务器下,右键单击安全文件夹,然后尝试这样做.然后您可以向该用户授予对适当数据库的权限

Before you add the user to the db, add the user to the server -- under the server, right click the security folder, and try it that way. Then you can grant permissions to the appropriate databases to that user

这篇关于如何在 SQL Server 2012 中创建可以在连接字符串中使用的新用户?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆