Login failed for user after database restore
Aric Levin
30,188
When using SQL Server logins to connect to a database that has just been restored, most likely the following error will appear: Login failed for User 'username'
When using SQL Server logins to conect to a database that has just been restored, most likely the following error will appear:
Login failed for User 'username'
or
Cannot open database 'dbname' requested by the login. The login failed. Login failed for user 'username'.
The reason for this error is that the user login and the database login have become disconnected. We need to relink the database user with the login:
sp_change_users_login 'UPDATE_ONE', 'username', 'username'
*This post is locked for comments