How to create a user name and password in SQL Server

[Introduction]

For databases, data security is very important, but how do we ensure its security it? How so that everyone can see their information, while others do not see the information, which need to use your everyday life always see the login screen. Now, no matter what software, it will remind you how to set up your own unique user name and password, a proprietary form when you first use. Only their own use, others can not see not move. QQ and micro letter like.

I will create a user database is divided into: set up the database, create a new SQL Server login Two Steps

Before you begin, now to share a URL associated SQL syntax:

https://docs.microsoft.com/en-us/sql/relational-databases/system-stored-procedures/sp-addlogin-transact-sql?view=sql-server-ver15

 

[ Text]

First, set the database to be operated

USE [My Table]

This sentence is in hint system, all commands are in accordance with the back of the My Table database operations.

But there is a heavy thing to note: My Table middle of this database names with spaces, you need to add square brackets ([]) the database name in quotes, otherwise it will error. I did not notice it at that time. After all, small details is the beginning of success

 

Second, create a new SQL Server login

Syntax I have to share the URL of involving very detailed introduction, not specifically about the

EXECUTE sp_addlogin @loginame = 'Bella', @passwd = 'ASDFG'
EXECUTE sp_addlogin @loginame = 'Kite', @passwd = 'qwerty'
EXECUTE sp_addlogin @loginame = 'Jackson', @passwd = 'ASDFG'
EXECUTE sp_addlogin @loginame = 'Tonny', @passwd = 'qwerty'
EXECUTE sp_addlogin @loginame = 'Cindy', @passwd = 'ASDFG'
EXECUTE sp_addlogin @loginame = 'CiCi', @passwd = 'qwerty'

用户创建SQL Server登录名Bella,密码为ASDFG
用户创建SQL Server登录名Kite,密码为ASDFG
...
EXECUTE sp_adduser 'Bella', 'Bella'
EXECUTE sp_adduser 'Kite', 'Kite'
EXECUTE sp_adduser 'Jackson', 'Jackson'
EXECUTE sp_adduser 'Tonny', 'Tonny'
EXECUTE sp_adduser 'Cindy', 'Cindy'
EXECUTE sp_adduser 'CiCi', 'CiCi'

将用户Bella添加到数据库中
将用户Kite添加到数据库中
...

Here use sp_addlogin to add users and databases are sp_adduser statements, allowing users to log into SQL Server using a specific user name and password. We like to check the final grade in school, the student number as the login name and password to access their own by setting a good score system queries.

 

【to sum up】

1. If the SQL Server Manager is not started, open it and start the service

2. Open Query Analyzer

3. Set the database to operate. USE database name (middle name of the database to add a space in square brackets)

4. Add the user login name and password

 

 

 

 

 

 

 

 

发布了36 篇原创文章 · 获赞 10 · 访问量 8174

Guess you like

Origin blog.csdn.net/weixin_43319713/article/details/104449626