Cannot connect to database,.Login failed for user

34,062

Solution 1

If you go to enterprise manager as a different user, go to the security, logins node and select the user - then change the default database to master.

That should sort it.

Solution 2

The reason is because the default database has been removed (look comment on the question). You have to Open Sql Server Management Studio, connect to the database, then open Security -> Logins-> right click on the account jangid -> Properties: on the bottom of the window you have to change the default database to the available one, or master.

Solution 3

Try this in SQL Server Management Studio.

1: Open 'Connect to Server' popup

2: Select 'Options >>'

3: Change the value in the dropdown 'Connect to database' from <default> to master.

Share:
34,062
Kishore Kumar
Author by

Kishore Kumar

OpenText Content Server Developer, Windows Developer, Web Designer &amp; Developer. Interested in VB.Net,C#,WPF,ASP.Net,ASP.Net MVC,XAML,WCF,OScript, BackboneJS, Marionette http://www.dignaj.com/kishore/

Updated on July 05, 2022

Comments

  • Kishore Kumar
    Kishore Kumar almost 2 years

    Yesterday my database was connected perfectly.

    We have installed Windows Server 2008 R2 on our server and the I have added the user to the client PC name SMTECH5 with user jangid

    Now my database is not connecting using windows authentication.

    only the master database is connecting.

    Here's the the error:

    Cannot connect to SMTECH5\COLLEGEERP.

    Cannot open user default database. Login failed.
    Login failed for user 'SMTECH\jangid'. (Microsoft SQL Server, Error: 4064)