Hi,
SQL Server 2005 installed on my computer. i was trying to make a login page with VS.2005 pro. But i got some errors on Website Administration Tool. Whatsoever, i registered a database (aspnetdb) . Then, i think i made my default database to aspnetdb. Something went wrong and i decided to delete aspnetdb and start whole procces from the begining and i did it. AAANDD WHOOOLA. I got this error:
Cannot Open User Default Database, Login Failed
Microsoft SQL Server, Error 4064
Is there anyway to change my default database to "master" again? Or simply will i uninstall all the sql server 2005?
(?f you say uninstall, answer this:: Will be any problem on VS 2005? I can't uninstall both :) )
Thanks
Laurentiu|||I don't think that Laurentiu understands the problem. I have run into the same situation, I am an administrator on the server, because the default database no longer exists (I had changed it from master) I can no longer connect. I would like to think that in the absence of my default database, it would revert to the master, but this is not the case. I'm unable to connect using the Administrator login to execute the ALTER LOGIN command.|||
You can resolve this by specifying another database you want to connect to; master, for example. Then you can reset the login's default database. With sqlcmd, you can do the following:
sqlcmd -d master -U sa -P mypassword
and then:
alter login sa with default_database = master
Thanks
Laurentiu
I already posted an answer above. You just need to specify a different database to use at connection time, then change your default database to an existing one.
I'll check to see if we have a KB article on this and pass your feedback to write one if we don't already have it.
Thanks
Laurentiu
I see now that you mentioned that you don't know sa's password.
sa was just provided as an example, for this operation you don't necessarily need to use sa to connect. You just need to connect with the login for which you've received this error. If you use Windows authentication, then you should connect like this:
sqlcmd -E -d master
then issue the ALTER LOGIN statement.
It's the "-d master" that's the key here - it specifies that the connection should be made to the master database, so the login won't try to connect to the database that no longer exists.
Hope this makes the solution clearer. If you still have problems with resetting the default database, let us know.
Thanks
Laurentiu
You should post to SQL Server Tools General, for Management Studio issues. You can also search for existing bugs on this issue or open a new one at: http://lab.msdn.microsoft.com/productfeedback/.
Thanks
Laurentiu
I got the same error with SQL Server Management Studio and could not resolve it with sa authentication because my config wouldn't let me log in as sa.
Selecting master as the connect database in the login dialog got me in. I then tried to edit my login object to change my default database, but this fails with the same error!
I then tried deleting my login. Failed again with error 4064.
Finally, I tried to right-click on the login object, and selected Script Login As > DROP to > New Query Editor Window, and then hit Execute in the view that appeared. It worked!
Hope this helps someone out there...
|||I just ran into the same issue after I dropped a database that was mistakenly set to be the default database. I found the information posted here pointed me in the right direction, but it didn't really help much because I couldn't figure out which user should be modified when SQL Server 2005 is configured to use Windows authentication (e.g. trusted connections) exclusively. After a lot of digging through SQL Server Books Online, executing various stored procedures to dump login information, and experimentation, I finally stumbled on the right combination.
C:\> sqlcmd -E -d master
1> ALTER LOGIN [BUILTIN\Administrators] WITH DEFAULT_DATABASE=master
2> GO
I show the prompts above so you can see where to type the commands and the expected results (e.g. SQLCMD does not output any information or error messages).
|||I detached a database on a network server with the idea of reattaching an updated version from my local db.
Evidently, the database I detached was the default database. I couldn't log in now because of the posts in this thread. I was able to log in using the Master db at the login dialog. However, I've tried everything in this post, and nothing seems to work!
When I try to execute a query against the master db (such as the sql in these posts), it executes fine. In the drop down list of available databases, the only thing it has is master... the rest says "server is not available". I'm able to ping it just fine.
I can't even restore the db I detached, because I get the same error msgs as not being able to log on. I desperately need to attach this database again with master as the default db.
How can I accomplish this? Can someone please help?
|||The only thing I can do with logging in as master, is simply just to look at objects. I cannot perform any action at all against anything because of the same error message (Cannot open user default database. Login failed for user sa...).
How can I resolve this!!!!
Microsoft, please help..........
|||For what it's worth, the db icazon next to the server is simply a white circle (no activity, etc)....|||
I tried what you're mentioning Chris and it didn't work.
In the query window I have the following:
IF EXISTS (SELECT * FROM sys.server_principals WHERE name = N'sa')
DROP LOGIN [sa]
The results state the following:
Msg 15405, Level 16, State 1, Line 3
Cannot use the special principal 'sa'.
No comments:
Post a Comment