I cannot login to my SQL Server database anymore!

When you attempt to login to your database using SQL Server Authentication and you get an error message that says:

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

It might possibly be due to the fact that the database that was set up to be the default for that specific login has been deleted. 

What you need to do is update the login to have a default database that you know exists. Here’s how to fix it. Open a command prompt and type the following:

For SQL 2005:
osql -S SQL01 -d master -U usrlogin -P usrpassword
ALTER LOGIN usrlogin WITH DEFAULT_DATABASE=new_default_db    

For SQL 2000:
isql -S SQL01 -d master -U usrlogin -P usrpassword
(opens query analyzer, type the next line in there)
sp_defaultdb ‘usrlogin’, ‘ new_default_db’   

If this didn’t fix the problem… try this link:
http://benharrell.wordpress.com/2007/01/15/cannot-open-user-default-database-login-failed-login-failed-for-user-username-microsoft-sql-server-error-4064/

One Response to “I cannot login to my SQL Server database anymore!”

Leave a Reply

*