Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 SQL Server Administration (2005)
 restoring DB (users/login problems)

Author  Topic 

mike123
Master Smack Fu Yak Hacker

1462 Posts

Posted - 2007-04-11 : 06:05:23

Hi,

I have a few db's that I am backing up from an old sql2000 system and moving them to the new sql2005 server. The first db's restored without any problems but now I am getting some problems with users and logins.

I am restoring in the following order

1.) Creating empty db "123"
2.) Restoring database from file to database "123"
3.) Creating Login to this database (error happens when linking it to the database, "user exists")

When connecting thru QA I get "Cannot open user default database login failed"

I only have 1 login per database and I don't mind manually deleting and recreating them all but it doesnt seem to be working :S



Any suggestions much appreciated!! :)

Thanks!
mike123

rmiao
Master Smack Fu Yak Hacker

7266 Posts

Posted - 2007-04-11 : 10:07:48
Connect to sql with as sysadmin and run sp_change_users_login to remap sql login to db user.
Go to Top of Page

mike123
Master Smack Fu Yak Hacker

1462 Posts

Posted - 2007-04-11 : 14:17:20
ok I will look into doing this.

I am still wondering why it was not necessary for my first 2 db's that I restored? Any idea?

Thanks!
mike123
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2007-04-11 : 14:21:01
Step1 isn't needed.

Step3 should happen before step2. Here is what I use to transfer my logins. I don't need to unoprhan any users after the restore as the sids are the same. Make sure to change the default database to master prior to running the add login if the default database doesn't exist yet.

http://www.sqlmag.com/articles/index.cfm?articleid=16090&



Tara Kizer
http://weblogs.sqlteam.com/tarad/
Go to Top of Page

rmiao
Master Smack Fu Yak Hacker

7266 Posts

Posted - 2007-04-11 : 14:48:37
And this issue will not happen on trusted sql logins.
Go to Top of Page
   

- Advertisement -