Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Create SQL users and delete SQL users

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

-- create SQL users and associate databases-- create new SQL users, and associate windows users to connect to SQL database CREATE LOGIN [huang-PC\ Fly_User] FROM WINDOWS WITH DEFAULT_DATABASE= [fly]-- PC\ User: including windows users and groups, as well as domain users and groups. -- Fly: the database name associated by the user by default. / *-- create SQL server user CREATE LOGIN [SQL_User] WITH PASSWORD=N'123123' MUST_CHANGE, DEFAULT_DATABASE= [Fly], CHECK_EXPIRATION=OFF, CHECK_POLICY=ON--SQL_User: user name. -- MUST_CHANGE: the next login must be modified. -- DEFAULT_DATABASE: default database -- CHECK_EXPIRATION: force the password to expire. -- CHECK_POLICY: enforces password policy. * / GO-- create database user name USE [Fly] GOCREATE USER [Fly_User] FOR LOGIN [huang-PC\ Fly_User] WITH DEFAULT_SCHEMA= [DBO]-- Fly_User: naming can be inconsistent with user name. -- dbo: schema name-- Delete database user and SQL user-- Delete database user IF EXISTS (SELECT * FROM Fly.sys.database_principals WHERE name = encrypted user user) DROP USER [Fly_User] ELSE Print 'does not have this database user' go-- deletes SQL login user IF EXISTS (SELECT * FROM msdb.sys.server_principals WHERE name = N'huang-PC\ Fly_User') DROP LOGIN [huang-PC\ Fly_User] ELSE print 'does not have this SQL login user'-- -

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report