在 SQL Azure 中如何创建只读用户
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2777422/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
In SQL Azure how can I create a read only user
提问by Sam Saffron
I would like to create an SQL Azure user and grant her read-only access on a handful of DBs, what script can I use to achieve this?
我想创建一个 SQL Azure 用户并授予她对少数数据库的只读访问权限,我可以使用什么脚本来实现这一点?
回答by Sam Saffron
A pure TSQL script is super messy, SQL Azure disables the USE
command, so you are stuck opening connections to each DB you need to give the user read access.
纯 TSQL 脚本非常混乱,SQL Azure 禁用该USE
命令,因此您无法打开与需要授予用户读取访问权限的每个数据库的连接。
This is the gist of the pattern.
这是模式的要点。
In Master DB:
在主数据库中:
CREATE LOGIN reader WITH password='YourPWD';
-- grant public master access
CREATE USER readerUser FROM LOGIN reader;
In each target DB (requires a separate connection)
在每个目标 DB 中(需要单独的连接)
CREATE USER readerUser FROM LOGIN reader;
EXEC sp_addrolemember 'db_datareader', 'readerUser';
回答by Frank Boucher
OR... Use the Azure User Management console - AUMCto manage the Logins and Users.
或...使用Azure 用户管理控制台 - AUMC来管理登录名和用户。
It's a open source project available on codeplex AUMC.codeplex.com
这是一个可在 codeplex AUMC.codeplex.com 上获得的开源项目
Project Description
Azure User Management Console - AUMC is a User Graphic Interface (GUI) that manages the users and logins of an Azure SQL database. The tool is simply converting your action into T-SQL commands and execute them on the Azure SQL Database.
项目描述
Azure 用户管理控制台 - AUMC 是一个用户图形界面 (GUI),用于管理 Azure SQL 数据库的用户和登录。该工具只是将您的操作转换为 T-SQL 命令并在 Azure SQL 数据库上执行它们。
A quick simple tool with a user interface! Don
一个带有用户界面的快速简单的工具!大学教师
Enjoy!
享受!
回答by Yury Dzhantuganov
You can create new user without creating login on masterDB (which is require make a separate connection)
您可以在不创建主数据库登录的情况下创建新用户(需要单独连接)
CREATE USER user1 WITH password='<Strong_Password>';
https://azure.microsoft.com/en-us/documentation/articles/sql-database-manage-logins/
https://azure.microsoft.com/en-us/documentation/articles/sql-database-manage-logins/