You just moved an existing site and a SQL Database to a new machine. Everything is ready to roll and now you are getting this error message:
Cannot open database "Your_DB_Name" requested by the login. The login failed. Login failed for user 'NT AUTHORITYNETWORK SERVICE'.
To fix this, you need to give user NT AUTHORITYNETWORK SERVICE access to your SQL database. There are two steps involved:
– (1) Add this user to SQL login and
– (2) Make this user your D/B owner.
You can do this using Query or through User Interface.
=01= Open use this command:
exec sp_grantlogin N'NT AUTHORITYNETWORK SERVICE' go
-02= Use these commands:
use Your_DB_Name go exec sp_addrolemember 'db_owner', N'NT AUTHORITYNETWORK SERVICE' go
If you like to use Management Studio User Interface, perform these steps:
=01= Go to Your SQL Instance –> Security –> Logins and add a new user: NT AUTHORITYNETWORK SERVICE
=02= Go to Your SQL Instance –> Databases –> Your Database –> Security –> Users –> NT AUTHORITYNETWORK SERVICE and check db_owner as a new user role.