May 26, 2019

How to Bypass a Sql Server Login Failure?


When you attempt to login to your database using SQL Server Authentication, you may get an error saying “Login failed. Login faile for user `usrLogin`. (Microsoft SQL Server, Error: 4064)”. This problem may occur if the database that was set to be the default for that specific login was deleted.

Steps

  1. 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:


SQL 2005

osql -S SQL01 -d master -U usrlogin -P usrpassword ALTER LOGIN

usrlogin WITH DEFAULT_DATABASE=new_default_db

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’

You may like our other article on  How to Reset Sa Password in Sql Server 2005

About Bhattarai Diwas (thenepaltech) 213 Articles
I'm an Engineer and have Bachelor's Degree in Electrical and information technology. Right now I am working as a software developer in Germany. All in all I love programming and I am a tech geek.