sqlserver SQL Server Management Studio和Transact-SQL创建账户、创建访问指定数据库的只读用户

文章目录

  • 前言
    • 1. Create a Login
    • 2. 创建访问指定数据库的只读用户
      • 备注:服务器角色

前言


1. Create a Login

sqlserver创建用户
Transact-SQL创建用户

文档中介绍了using SQL Server Management Studio (SSMS)Transact-SQL2种方式,本人创建只读账户使用的第一种方式;


2. 创建访问指定数据库的只读用户

   (1)使用Microsoft SQLServer Management Studio,用管理员账户登录
sqlserver SQL Server Management Studio和Transact-SQL创建账户、创建访问指定数据库的只读用户_第1张图片

   (2)点击【安全性】->【登录名】,选择【新建登录名
sqlserver SQL Server Management Studio和Transact-SQL创建账户、创建访问指定数据库的只读用户_第2张图片

   (3)在【常规】选项【登录名】中输入用户名 cz。身份验证选择【SQL Server 身份验证】,输入密码,取消勾选【强制实施密码策略
sqlserver SQL Server Management Studio和Transact-SQL创建账户、创建访问指定数据库的只读用户_第3张图片

   (4)点击选项页【用户映射】->【映射到此登录名的用户】,选择创建的cz用户可操作的数据库。针对每一个数据库,在下方【数据库角色成员身份】中勾选成员身份,即可获取身份对应的权限,如只读权限,即勾选【db_datareader】。同时【默认架构】中亦勾选【db_datareader】
sqlserver SQL Server Management Studio和Transact-SQL创建账户、创建访问指定数据库的只读用户_第4张图片
sqlserver SQL Server Management Studio和Transact-SQL创建账户、创建访问指定数据库的只读用户_第5张图片

   (6)只读用户cz创建成功
sqlserver SQL Server Management Studio和Transact-SQL创建账户、创建访问指定数据库的只读用户_第6张图片
连接成功:
sqlserver SQL Server Management Studio和Transact-SQL创建账户、创建访问指定数据库的只读用户_第7张图片
修改数据报错:
在这里插入图片描述


备注:服务器角色

sqlserver SQL Server Management Studio和Transact-SQL创建账户、创建访问指定数据库的只读用户_第8张图片

bulkadmin check box
Members of the bulkadmin fixed server role can run the BULK INSERT statement.

dbcreator check box
Members of the dbcreator fixed server role can create, alter, drop, and restore any database.

diskadmin check box
Members of the diskadmin fixed server role can manage disk files.

processadmin check box
Members of the processadmin fixed server role can terminate processes running in an instance of the Database Engine.

public check box
All SQL Server users, groups, and roles belong to the public fixed server role by default.

securityadmin check box
Members of the securityadmin fixed server role manage logins and their properties. They can GRANT, DENY, and REVOKE server-level permissions. They can also GRANT, DENY, and REVOKE database-level permissions. Additionally, they can reset passwords for SQL Server logins.

serveradmin check box
Members of the serveradmin fixed server role can change server-wide configuration options and shut down the server.

setupadmin check box
Members of the setupadmin fixed server role can add and remove linked servers, and they can execute some system stored procedures.

sysadmin check box
Members of the sysadmin fixed server role can perform any activity in the Database Engine.

你可能感兴趣的:(sqlserver,sqlserver)