Sql Server – Fix – Cannot open user default database. Login failed for user ‘testlogin’. (Microsoft SQL Server, Error: 4064)

We created login and password for user to access database in read only mode.  But after creating login name when user tries to login, it failed to access the sql server.

Error: Cannot open user default database. Login failed. Login failed for user ‘testlogin’. (Microsoft SQL Server, Error: 4064)

Login failed to access sql server

Login failed to access sql server

As error suggests, there is some issue with default database. Now let’s check the login properties whether we have assign correct default database for login.

Default database is correct but user mapping was missing.

Login properties to access sql server

No user mapping to access default database

assign permission to login

To fix this issue, we have to assign db_reader database role permission to login to access default database on sql server.

User Mapping in sql server

 

Now after assigning proper permission to user and user mapping, we retried accessing sql server this time it got logged in.

Leave a Reply

  

  

  


− 4 = 1