当前位置:网站首页>[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
边栏推荐
猜你喜欢
RustDesk 搭建一个自己的远程桌面中继服务器
Text classification still stays at Bert? The dual contrast learning framework is too strong
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
[SQL Server Express Way] - authentification et création et gestion de comptes utilisateurs
Cuda11.1 online installation
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
B站刘二大人-线性回归 Pytorch
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
In 2022, we must enter the big factory as soon as possible
Pix2pix: image to image conversion using conditional countermeasure networks
随机推荐
剑指 Offer II 039. 直方图最大矩形面积
First acquaintance with CDN
什么是独立IP,独立IP主机怎么样?
[QNX hypervisor 2.2 user manual]6.3.3 using shared memory (shmem) virtual devices
UCF (2022 summer team competition I)
Summary of deep learning tuning tricks
jdbc使用call调用存储过程报错
Problems encountered in installing mysql8 on MAC
29io stream, byte output stream continue write line feed
Application Security Series 37: log injection
Easy to understand IIC protocol explanation
ArcGIS应用基础4 专题图的制作
Remember an error in MySQL: the user specified as a definer ('mysql.infoschema '@' localhost ') does not exist
Force buckle 1189 Maximum number of "balloons"
[cloud native] 3.1 kubernetes platform installation kubespher
Graduation design game mall
Sword finger offer II 039 Maximum rectangular area of histogram
【SQL server速成之路】——身份验证及建立和管理用户账户
Unity Vector3. Use and calculation principle of reflect
Can the feelings of Xi'an version of "Coca Cola" and Bingfeng beverage rush for IPO continue?