Bind the user and login name of the sql server database

The server reinstalls the system, reinstalls the sql server, and attaches the previous database.

Then each database used to have a login for operating the database, and other databases could not operate,

After the database is attached, the users in the security of the database can see the previously established users, but there is no corresponding user in the login name of the system-level security outside. Once a user is logged in, the user is directly prompted that the user already exists.

I searched online and found the solution as follows:

For system-level security, create a new user with the same name in the login name, and do not select anything in the authorization area, so that the user will not be prompted that the user already exists, and then execute the following SQL statement to associate the database user with the login name:

use qikai_guanwang
go
sp_change_users_login 'update_one' , 'qikai' , 'qikai'

 

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326306915&siteId=291194637