Sunday, February 19, 2012

Connection

When I try to connect to my database using enterprise manager I get this error:
A connection could not be established to DBSERVER
Reason: Cannot open user default database. Login failed..
I have know that the server is running and the agent is running. There is
no login issues because I was able to login just mins before this happen. I
tried to change the default db with osql utility. I have restarted the
dbserver and still have the same issue. Can anyone if me an idea of what I
need to do.
The SQL login you're trying to use to connect to your SQL server has a
default database defined that either they don't have access to or does
not exist. To get yourself going again you can probably just login to
your server using osql with:
(assuming it's your trusted login you're having problems with)
osql -S MyServer -d master -E
or
(assuming it's a particular SQL login you're having trouble with)
osql -S MyServer -d master -U MyUsername -P MyPassword
And then change your the default DB for that login:
(assuming it's your trusted login...)
1> exec sp_defaultdb @.loginame='MyDomain\MyLogin', @.defdb='master'
2> go
or
(assuming it's a SQL login you're having problems with)
1> exec sp_defaultdb @.loginame='MyUsername', @.defdb='master'
2> go
This should fix up the login you're having issues with by virtue of the
fact that every login on the server can access the master DB.
*mike hodgson*
blog: http://sqlnerd.blogspot.com
new admin wrote:

>When I try to connect to my database using enterprise manager I get this error:
>A connection could not be established to DBSERVER
>Reason: Cannot open user default database. Login failed..
>I have know that the server is running and the agent is running. There is
>no login issues because I was able to login just mins before this happen. I
>tried to change the default db with osql utility. I have restarted the
>dbserver and still have the same issue. Can anyone if me an idea of what I
>need to do.
>
>
|||Thank you soooo much that got me in and now I see that my default db is
(subspect)
"Mike Hodgson" wrote:

> The SQL login you're trying to use to connect to your SQL server has a
> default database defined that either they don't have access to or does
> not exist. To get yourself going again you can probably just login to
> your server using osql with:
> (assuming it's your trusted login you're having problems with)
> osql -S MyServer -d master -E
> or
> (assuming it's a particular SQL login you're having trouble with)
> osql -S MyServer -d master -U MyUsername -P MyPassword
> And then change your the default DB for that login:
> (assuming it's your trusted login...)
> 1> exec sp_defaultdb @.loginame='MyDomain\MyLogin', @.defdb='master'
> 2> go
> or
> (assuming it's a SQL login you're having problems with)
> 1> exec sp_defaultdb @.loginame='MyUsername', @.defdb='master'
> 2> go
> This should fix up the login you're having issues with by virtue of the
> fact that every login on the server can access the master DB.
> --
> *mike hodgson*
> blog: http://sqlnerd.blogspot.com
>
> new admin wrote:
>

No comments:

Post a Comment