What SQL Server Login Failed Error 4064?
When default database is not available during the connection, the user will not be unable to connect to the database as a result an error code 4064 prompt on the screen.
Cannot open default database. Login failed.
Login failed for user ‘UserName’.(Microsoft SQL Server, Error: 4064)
Reasons of the Microsoft SQL Server Error 4064 Login Failed
When the error "cannot open user default database login failed error 4064" occurs, it may be possible that the default database for connection is not specified. There are many other possible reasons for this error. Some of them are stated below:
- The database may be in Suspect Mode or no longer exists on the server.
- It may also be possible that the database has been going into emergency mode.
- It is also possible that the database has been set to RESTRICTED_USER state.
- The database is in single user mode and it is already being used by any other user.
- The user who is trying to connect with the database has not mapped the login account or user has been denied access.
- It is also possible that the database is a part of mirroring or it could be that the database has been detached.
Fix Cannot Open Default Database Error 4064
Lets have a look at the steps to fix “login failed for the user Microsoft SQL Server Error 4064”.
- Firstly, open the SQL Server Management Studio.
- Now select the click on Security button. On Connect to Server window you will notice that there is no database assigned as the default database.
- Go to the Connection Properties and specify a database as test_db and click on the Connect button.
- After connecting to SQL Server instance you need to run the given T-SQL query to assign the login account for the new assigned default database.
ALTER LOGIN [MonitorDB] WITH DEFAULT_DATABASE = test_db
In this article, we have discussed why "cannot open user default database login failed 4064" error occurs. Here, we have also discussed, how can we fix Microsoft SQL Server 4064.