如何在sql azure中设置数据库的权限?

时间:2023-01-02 07:22:33

Could anyone please tell me how to grant permissions for database in SQL Azure?

有谁能告诉我如何在SQL Azure中授予数据库权限?

When I execute create table query, I am ending up with following message:

当我执行create table query时,我最终得到以下消息:

CREATE TABLE permission denied in database testDB

数据库testDB中的CREATE TABLE权限被拒绝

Thanks in advance :)

提前致谢 :)

5 个解决方案

#1


6  

Ideally, you'd assign only the the permissions needed for the user. If you've just created a new user that you want to be able do anything in the new database, you can run the following command inside of that database using a server admin user:

理想情况下,您只需分配用户所需的权限。如果您刚刚创建了一个新用户,希望能够在新数据库中执行任何操作,则可以使用服务器管理员用户在该数据库中运行以下命令:

EXEC sp_addrolemember 'db_owner', 'YourNewUser';

#2


3  

Take a look at these scripts .This may not be the exact script that you are looking for.But this will help you create the script that you want

看看这些脚本。这可能不是您正在寻找的确切脚本。但这将帮助您创建所需的脚本

STEP1 : Ran these scripts on azure masterdb

第1步:在azure masterdb上运行这些脚本

CREATE LOGIN mydb_admin 
WITH PASSWORD = 'nnn' 
GO
CREATE LOGIN mydb_user 
WITH PASSWORD = 'nnnnnnnnn
GO

'

Step2: Ran the below scripts on the actual azure db  eg., mydb

步骤2:在实际的天蓝色数据库上运行以下脚本,例如,mydb

CREATE USER mydb_admin  FROM LOGIN mydb_admin ;
EXEC sp_addrolemember 'db_datareader', 'mydb_admin';
EXEC sp_addrolemember 'db_datawriter', 'mydb_admin';
GRANT CONNECT TO mydb_admin;
GRANT SELECT TO mydb_admin;
GRANT EXECUTE ON [dbo].[procDumpRowsInto_De_Common] TO [mydb_admin] AS [dbo]

CREATE USER mydb_user FROM LOGIN mydb_user;
EXEC sp_addrolemember 'db_datareader', 'mydb_user';
EXEC sp_addrolemember 'db_executor', 'mydb_user';
GRANT CONNECT TO mydb_user;
GRANT SELECT TO mydb_user;

#3


1  

have a look at: Managing Databases and Logins in SQL Azure

看看:在SQL Azure中管理数据库和登录

#4


1  

Ensure that you're not trying to run the create table script in the master database.

确保您没有尝试在master数据库中运行create table脚本。

#5


0  

SQL Azure uses the same security mode as SQL Server. Looks like you use a non-dbo user to create table. I think you can use the GRANT command it get the proper permission.

SQL Azure使用与SQL Server相同的安全模式。看起来您使用非dbo用户来创建表。我认为您可以使用GRANT命令获得适当的权限。

#1


6  

Ideally, you'd assign only the the permissions needed for the user. If you've just created a new user that you want to be able do anything in the new database, you can run the following command inside of that database using a server admin user:

理想情况下,您只需分配用户所需的权限。如果您刚刚创建了一个新用户,希望能够在新数据库中执行任何操作,则可以使用服务器管理员用户在该数据库中运行以下命令:

EXEC sp_addrolemember 'db_owner', 'YourNewUser';

#2


3  

Take a look at these scripts .This may not be the exact script that you are looking for.But this will help you create the script that you want

看看这些脚本。这可能不是您正在寻找的确切脚本。但这将帮助您创建所需的脚本

STEP1 : Ran these scripts on azure masterdb

第1步:在azure masterdb上运行这些脚本

CREATE LOGIN mydb_admin 
WITH PASSWORD = 'nnn' 
GO
CREATE LOGIN mydb_user 
WITH PASSWORD = 'nnnnnnnnn
GO

'

Step2: Ran the below scripts on the actual azure db  eg., mydb

步骤2:在实际的天蓝色数据库上运行以下脚本,例如,mydb

CREATE USER mydb_admin  FROM LOGIN mydb_admin ;
EXEC sp_addrolemember 'db_datareader', 'mydb_admin';
EXEC sp_addrolemember 'db_datawriter', 'mydb_admin';
GRANT CONNECT TO mydb_admin;
GRANT SELECT TO mydb_admin;
GRANT EXECUTE ON [dbo].[procDumpRowsInto_De_Common] TO [mydb_admin] AS [dbo]

CREATE USER mydb_user FROM LOGIN mydb_user;
EXEC sp_addrolemember 'db_datareader', 'mydb_user';
EXEC sp_addrolemember 'db_executor', 'mydb_user';
GRANT CONNECT TO mydb_user;
GRANT SELECT TO mydb_user;

#3


1  

have a look at: Managing Databases and Logins in SQL Azure

看看:在SQL Azure中管理数据库和登录

#4


1  

Ensure that you're not trying to run the create table script in the master database.

确保您没有尝试在master数据库中运行create table脚本。

#5


0  

SQL Azure uses the same security mode as SQL Server. Looks like you use a non-dbo user to create table. I think you can use the GRANT command it get the proper permission.

SQL Azure使用与SQL Server相同的安全模式。看起来您使用非dbo用户来创建表。我认为您可以使用GRANT命令获得适当的权限。