标签:
Login 用于登陆SQL Server
1,Create Sql Server login
CREATE LOGIN TestLoginName with password=‘J345#$)thb‘ ,DEFAULT_DATABASE = db_study
PASSWORD =‘password‘
Applies to SQL Server logins only. Specifies the password for the login that is being created. You should use a strong password. For more information see Strong Passwords and Password Policy.
Passwords are case-sensitive. Passwords should always be at least 8 characters long, and cannot exceed 128 characters. Passwords can include a-z, A-Z, 0-9, and most non-alphanumeric characters. Passwords cannot contain single quotes, or the login_name.
DEFAULT_DATABASE =database
Specifies the default database to be assigned to the login. If this option is not included, the default database is set to master.
DEFAULT_LANGUAGE =language
Specifies the default language to be assigned to the login. If this option is not included, the default language is set to the current default language of the server. If the default language of the server is later changed, the default language of the login remains unchanged.
2,Creating a login from a Windows domain account
CREATE LOGIN [<domainName>\<login_name>] FROM WINDOWS;
login_name
Specifies the name of the login that is created. When you are creating logins that are mapped from a Windows domain account, you must use the pre-Windows 2000 user logon name in the format [<domainName>\<login_name>].
3,Next Steps
After creating a login, the login can connect to the Database Engine, but only has the permissions granted to the public role. Consider performing the some of the following activities.
To connect to a database, create a database user for the login. For more information, see CREATE USER (Transact-SQL).
Create a user-defined server role by using CREATE SERVER ROLE (Transact-SQL). Use ALTER SERVER ROLE … ADD MEMBER to add the new login to the user-defined server role. For more information, see CREATE SERVER ROLE (Transact-SQL) and ALTER SERVER ROLE (Transact-SQL).
Use sp_addsrvrolemember to add the login to a fixed server role. For more information, see Server-Level Roles and sp_addsrvrolemember (Transact-SQL).
Use the GRANT statement, to grant server-level permissions to the new login or to a role containing the login. For more information, see GRANT (Transact-SQL).
参考文档:
https://msdn.microsoft.com/en-us/library/ms189751(v=sql.110).aspx
标签:
原文地址:http://www.cnblogs.com/ljhdo/p/5125140.html