In a SharePoint 2013 to SharePoint 2016 migration, Got this error message on testing the content database with Test-SPContentDatabase cmdlet to identify possible issues:
“Cannot open database [Database Name] requested by the login. The login failed”
- If your databases are hosted on a different SQL Server or instance, other than the default SharePoint database server as its config database: Use -ServerInstance parameter with Test-SPContentDatabase cmdlet, because SharePoint always tries to find the database on the default database server. E.g.
Test-SpContentDatabase -name "WSS_Content_KM_New" -webapplication http://portal.crescent.com -ServerInstance "SQL001\SharePoint"
- Test-SPContentDatabase is running from the context of the SharePoint Farm Administrator account. So make sure the Farm Account has enough access to the content database! Go to SQL Server >> Security >> Under Logins right-click on your Farm Admin Account and select Properties. Under “User Mapping” tab >> Select your SharePoint content database >> Check the db_owner role.
- Try running the PowerShell as an administrator.
If you get this “Cannot open database ‘Database Name’ requested by the login. The login failed” issue in case of orphaned databases. Follow this article to fix it: Cannot open database ‘WSS_Content’ Requested by the login. The login failed.