Error in login to SQL Server

前端 未结 3 2106
眼角桃花
眼角桃花 2021-02-18 17:55

When I want to connect to SQL Server 2008, I get this message:

Cannot connect to server.
Additional Information: Cannot open user default database.

相关标签:
3条回答
  • 2021-02-18 18:13

    This error (Microsoft SQL Server.Error:4064) occurs when the database which is dropped is default for some database user.

    When the user tries to login and their default database is dropped the error shows up.

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

    The way to resolve this is given here, summarized below.

    The solution to log on is:

    1. From the Connect to Server dialog, click Options
    2. Change value of Connect to database: to any valid database on the server

    The permanent solution to fix the server is to run SQL like:

    ALTER LOGIN [test] WITH DEFAULT_DATABASE = master
    GO
    
    0 讨论(0)
  • 2021-02-18 18:21

    In my case this was due to a user being a member of multiple groups, each group having its own login. All groups' logins need to have their default database set to a database accessible to the user.

    Other possible problems are listed at https://support.microsoft.com/en-us/kb/307864.

    You can set each login with an invalid default database to have a default database of master (accessible to all logins):

    alter login [loginname] with DEFAULT_DATABASE = master
    
    0 讨论(0)
  • 2021-02-18 18:38

    The user default database is unavailable at the time of connection so that this error message will popup .SO check which server you tagged to that particular user to access whether it is online or offline mode.

    0 讨论(0)
提交回复
热议问题