当前位置:网站首页>[SQL Server fast track] - authentication and establishment and management of user accounts
[SQL Server fast track] - authentication and establishment and management of user accounts
2022-07-06 05:36:00 【I thought about this nickname for 20 minutes】

Personal home page : I thought about this nickname 20 minute
Previous columns :【 A quick way 】jQuery
【 A quick way 】Ajax
️ This column :【 A quick way 】SQL server

SQL Server 2012 Authentication mode for
Sql server Safety management is reflected in the following aspects :
Authenticate user logins . When the user logs in to the database system , The system verifies the user's account and password , It includes confirming whether the user's account is valid and can access the database system .
Perform permission control on the user's operations . When the user logs in to the database system , You can only operate on the data in the database within the allowed permissions .
A user performs some operation on a database , The following must be satisfied 3 Conditions :
- Sign in Sql server The server must be authenticated ;
- Must be a user of the database , Or a member of a certain role ;
- You must have permission to perform this operation .
SQL Server2012 There are two authentication modes :Windows Verification mode and SQL Server Verification mode . As shown in the figure, login in these two modes SQL server Server situation .
1.Windows Verification mode
Here's how Windows Some important notes on login in authentication mode :
(1) Must be Windows Add an account to SQL Server in , Can be used Windows The account login SQL Server.
(2) If you use Windows Account login to another network SQL Server, Must be in Windows Set each other's hosting permissions in .
2.SQL Server Verification mode
stay SQL Server In verification mode ,SQL Server The server needs to authenticate the logged in user . When SQL Server stay Windows When running on the operating system , The type of login authentication mode set by the system administrator can be Windows Validation mode and mixed mode . When using mixed mode ,SQL Server The system allows both Windows Login account login , It is also allowed to use SQL Server Login account login .
Establish and manage user accounts
1. Manage user accounts in the interface mode
1. establish Windows Login for authentication mode
(1) establish Windows Users of . Log in to as administrator Windows , open “ Control panel ”, Add a new account to the management account .
(2) take Windows Add an account to SQL Server in . Log in to as administrator SQL Server Management Studio, stay “ Object explorer ” in , an “ Security ” node , And right-click “ Login name ” term , choice “ New login ” A menu item , As shown in the figure .
open “ Login name - newly build ” window . As shown in the figure , You can click “ routine ” Tab “ Search for ” Button , stay “ Select users or groups ” Dialog box, select the corresponding user name or user group to add to SQL Server 2012 Log in to the user list .
2. establish SQL Server Login for authentication mode
To build SQL Server Login for authentication mode , First set the verification mode to mixed mode .
(1) Log in as system administrator SQL Server Management Studio, stay “ Object explorer ” Select the to log in to SQL Server Server icon , Right click mouse , Choose... From the shortcut menu that pops up “ attribute ” A menu item , open “ Server properties ” window .
(2) On the “ Server properties ” Select in window “ Security ” tab . Select server authentication as “SQL Server and Windows Authentication mode ”, single click “ determine ” Button , Save the new configuration , restart SQL Server The service can be .
stay “ Object explorer ” Click in the window “ Connect ”, Select... From the drop-down box “ Database engine ”, eject “ Connect to the server ” Dialog box . In this dialog box ,“ Authentication ” choice “SQL Server Authentication ”,“ Login name ” Fill in Jhon, Input password , single click “ Connect ” Button , You can connect SQL Server 了 .
3. Managing database users
The steps to create a database user account in the interface mode are as follows ( With xsbook Database, for example ):
Connect as a system administrator SQL Server, an “ database ”→“xsbook”→“ Security ”→ choice “ user ”, Right click mouse , choice “ A new user ” A menu item , Get into “ Database users - newly build ” window . stay “ user name ” Box to fill in a database user name ,“ Login name ” Box to log in to SQL Server Login name of .
Be careful : One login name can only create one database user in this database . Select the default schema as dbo, As shown in the figure , single click “ determine ” Button to finish creating .

2. Manage user accounts by command
1. Create login
stay SQL Server 2012 in , To create a login, you can use CREATE LOGIN command . Grammar format :
CREATE LOGIN < Login name >
{ WITH PASSWORD = 'password' [ HASHED ] [ MUST_CHANGE ]
[ , <option_list> [ ,... ] ] /*WITH Clause is used to create SQL Server Login name */
| FROM /*FROM Clause is used to create Windows Login name */
WINDOWS [ WITH <windows_options> [ ,... ] ]
}
among :
<option_list> ::=
SID = sid
| DEFAULT_DATABASE = database
| DEFAULT_LANGUAGE = language
| CHECK_EXPIRATION = { ON | OFF}
| CHECK_POLICY = { ON | OFF}
[ CREDENTIAL = credential_name ]
<windows_options> ::=
DEFAULT_DATABASE = database
| DEFAULT_LANGUAGE = language
explain :
(1) establish Windows Authentication mode login . establish Windows The login name uses FROM Clause , stay FROM Clause in the syntax format ,WINDOWS Keyword specifies that a login is mapped to Windows Login name , among ,<windows_options> Create for Windows Login options ,DEFAULT_DATABASE Specify the default database ,DEFAULT_LANGUAGE Specify the default language .
【 example 1】 Create by command Windows Login name tao( hypothesis Windows user tao Created , The local computer name is DAVID-PC), The default database is set to xsbook.
USE master
GO
CREATE LOGIN [DAVID-PC\tao]
FROM WINDOWS
WITH DEFAULT_DATABASE= xsbook
(2) establish SQL Server Authentication mode login . establish SQL Server The login name uses WITH Clause , among :
- PASSWORD: Password used to specify the login being created ,password Is the password string .
- <option_list>: Used to specify when creating SQL Server Some options for login .
【 example 2】 establish SQL Server Login name sql_tao, The password for 123456, The default database is set to xsbook.
CREATE LOGIN sql_tao
WITH PASSWORD='123456',
DEFAULT_DATABASE=xsbook
2. Delete login
Delete login using DROP LOGIN command . Grammar format :
DROP LOGIN < Login name >
for example , Delete Windows Login name tao.
DROP LOGIN [DAVID-PC\tao]
Delete SQL Server Login name sql_tao.
DROP LOGIN sql_tao
3. Create database users
Create database users to use CREATE USER command . Grammar format :
CREATE USER < user name >
[{ FOR | FROM } LOGIN < Login name > | WITHOUT LOGIN ]
[ WITH DEFAULT_SCHEMA = schema_name ]
explain :
(1)FOR or FROM Clause is used to specify the login associated with the user name .
(2)LOGIN Specify the... To create the database user SQL Server Login name , Must be a valid login in the server .
(3)WITHOUT LOGIN Specify that users are not mapped to existing logins .
(4)WITH DEFAULT_SCHEMA Specifies the first schema that the server will search when resolving object names for this database user , The default is dbo.
【 example 3】 Use SQL Server Login name sql_tao( Suppose you have created ) stay xsbook Create database users in the database tao, The default schema name uses dbo.
USE xsbook
GO
CREATE USER tao
FOR LOGIN sql_tao
WITH DEFAULT_SCHEMA=dbo
4. Delete database users
Delete database user usage DROP USER sentence . Grammar format :
DROP USER < user name >
【 example 4】 Delete xsbook Database user of the database tao.
USE xsbook
GO
DROP USER tao

边栏推荐
- 【OSPF 和 ISIS 在多路访问网络中对掩码的要求】
- [leetcode16] the sum of the nearest three numbers (double pointer)
- Codeforces Round #804 (Div. 2) Editorial(A-B)
- RustDesk 搭建一个自己的远程桌面中继服务器
- Pickle and savez_ Compressed compressed volume comparison
- After the project is released, index Html is cached
- [cloud native] 3.1 kubernetes platform installation kubespher
- ArcGIS应用基础4 专题图的制作
- [mask requirements of OSPF and Isis in multi access network]
- Self built DNS server, the client opens the web page slowly, the solution
猜你喜欢

Cuda11.1 online installation

Vulhub vulnerability recurrence 73_ Webmin

指針經典筆試題

Easy to understand IIC protocol explanation

SequoiaDB湖仓一体分布式数据库2022.6月刊

Self built DNS server, the client opens the web page slowly, the solution
![[force buckle]43 String multiplication](/img/fd/de63e6185af4b6293e748aaf7cee29.jpg)
[force buckle]43 String multiplication
![[JVM] [Chapter 17] [garbage collector]](/img/f4/e6ff0e3edccf23399ec12b7913749a.jpg)
[JVM] [Chapter 17] [garbage collector]

05. 博客项目之安全
![[leetcode] 18. Sum of four numbers](/img/06/c160b47d756290e5474e4c07e68648.png)
[leetcode] 18. Sum of four numbers
随机推荐
LeetCode_字符串反转_简单_557. 反转字符串中的单词 III
B站刘二大人-线性回归 Pytorch
JS array list actual use summary
04. Project blog log
用StopWatch 统计代码耗时
图数据库ONgDB Release v-1.0.3
[detailed explanation of Huawei machine test] check whether there is a digital combination that meets the conditions
Self built DNS server, the client opens the web page slowly, the solution
05. Security of blog project
Promotion hung up! The leader said it wasn't my poor skills
Unity Vector3. Use and calculation principle of reflect
[effective Objective-C] - memory management
Knowledge points of circular structure
Sword finger offer II 039 Maximum rectangular area of histogram
Selective parameters in MATLAB functions
The ECU of 21 Audi q5l 45tfsi brushes is upgraded to master special adjustment, and the horsepower is safely and stably increased to 305 horsepower
Vulhub vulnerability recurrence 67_ Supervisor
[detailed explanation of Huawei machine test] statistics of shooting competition results
Auto.js学习笔记17:基础监听事件和UI简单的点击事件操作
[machine learning notes] univariate linear regression principle, formula and code implementation