MS SQL] DB Restore 시 SQL 로그인 계정과 DB계정 매핑안될 때
MS SQL 에서 DB Restore시 SQL 계정과 DB에 생성되어 있는 계정이 매핑되지 않는 경우가 있는데 이런 경우 사용하는 명령입니다.
아래와 같이 Auto Fix 옵션과 로그인 계정정보를 넣으면 msdb에서 정보를 수정해 준다고 합니다.
EXEC sp_change_users_login 'Auto_Fix', 'sql_login_id'
MSDN 참고
Syntax
sp_change_users_login [ @Action = ] 'action'
[ , [ @UserNamePattern = ] 'user' ]
[ , [ @LoginName = ] 'login' ]
[ , [ @Password = ] 'password' ]
|
Arguments
[ @Action = ] 'action'
Describes the action to be performed by the procedure. action is varchar(10). action can have one of the following values.
Value
|
Description
|
Auto_Fix
|
Links a user entry in the sys.database_principals system catalog view in the current database to a SQL Server login of the same name. If a login with the same name does not exist, one will be created. Examine the result from theAuto_Fix statement to confirm that the correct link is in fact made. Avoid using Auto_Fix in security-sensitive situations.
When you use Auto_Fix, you must specify user and password if the login does not already exist, otherwise you must specify user but password will be ignored. login must be NULL. user must be a valid user in the current database. The login cannot have another user mapped to it.
|
Report
|
Lists the users and corresponding security identifiers (SID) in the current database that are not linked to any login. user, login, and password must be NULL or not specified.
|
Update_One
|
Links the specified user in the current database to an existing SQL Serverlogin. user and login must be specified. password must be NULL or not specified.
|
[ @UserNamePattern = ] 'user'
Is the name of a user in the current database. user is sysname, with a default of NULL.
[ @LoginName = ] 'login'
Is the name of a SQL Server login. login is sysname, with a default of NULL.
[ @Password = ] 'password'
Is the password assigned to a new SQL Server login that is created by specifying Auto_Fix. If a matching login already exists, the user and login are mapped and password is ignored. If a matching login does not exist, sp_change_users_login creates a new SQL Server login and assigns password as the password for the new login. password is sysname, and must not be NULL.
Security Note:
|
Use a strong password. For more information, see Strong Passwords.
|
댓글
댓글 쓰기