I have received following question nearly 10 times in last week though emails. Many users have received following error while connecting to the database. This error happens when database is dropped for which is default for some of the database user. When user try to login and their default database is dropped following error shows up.
Cannot open user default database. Login failed.
Login failed for user ‘UserName’. (Microsoft SQL Server, Error: 4064)
The fix for this problem is very simple.
Fix/Workaround/Solution:
First click on Option>> Button of “Connect to Server” Prompt.
Now change the connect to database to any existing database on your server like master or msdb.
Now click on connect and it will successfully log you in. Once you login in the system run following statement for your username and it should fix your problem. Make sure to replace [test] with your username and master with yourdatabase name.
ALTER LOGINÂ [test] WITH DEFAULT_DATABASE = master
GO
Watch SQL in Sixty Seconds video to Resolve Connection Error:
[youtube=http://www.youtube.com/watch?v=1k00z82u4OI]
Reference : Pinal Dave (http://www.SQLAuthority.com)
282 Comments. Leave new
Perfect advice…as always.
Hi,
I am currently working on PL/SQL, want to learn SQL server. Can you tell me is there any default database for SQL server which I can download and practice locally. If so, how to download it and wherefrom to connect it.
Thanks and regards.
Awesome!!! it really helped
WEW. worked great T_T
Thanks
thanks, it works for me
Dear sir,
I have update my SQL server through internet yesterday but today when i open my SQL ( please Insert a disk into CD Drive (D:). )) could you please guide me.
Are you getting that while opening Management Studio?
ThAnKs!!
This fixed the 4064 problem for me:
Log into SQL Server via Management Studio, as “sa”, go to Security=>Logins, right click on the user in question, select Properties.
Look at General page.
What is the Default database, at bottom?
That needs to be one of the databases selected in the User Mapping page, Map column.
thanks..
thanks.. worked for me!!
SQL010 – Thanks for your comment
Thanks a ton.! juss wrkd great.!!!
Very helpful. Thank you!!
it worked! thanks a Lot. I am so grateful. Wasted tons of time.
it worked thank you very much
Thanks It helps
Welcome Chetan!
I solved my problem coming here….
Thanks a lot…
Keep helping
Thanks nice! U are really good man! U are genius!
Very good!
Thanks a lot!! Your suggestion just saved many hours :)
Your welcome tabs!