简体   繁体   English

服务器之间的数据库副本-用户登录已损坏

[英]Database copy between servers - user logins corrupted

When I copy a database from one server to another via backup and restore, I find I have to recreate the users in the database. 通过备份和还原将数据库从一台服务器复制到另一台服务器时,我发现必须在数据库中重新创建用户。 I can't login as them right after the copy - I get cannot open default database, when the database that was just copied is the default database. 复制后,我无法立即以他们的身份登录-当刚复制的数据库是默认数据库时,我无法打开默认数据库。 Why is this? 为什么是这样? The logins exist on the target copy server. 登录名存在于目标副本服务器上。

The logins don't actually exist on the target copy server -- it just has logins that happen to have the same name. 这些登录实际上并不存在于目标复制服务器上-它只是具有恰好具有相同名称的登录。 Internally, all logins are SIDs and since the SID for 'joesmith' on the target server is different from the SID for 'joesmith' on the origin server, they're not considered the same user even though the name is the same. 在内部,所有登录名都是SID,并且由于目标服务器上“ joesmith”的SID与源服务器上“ joesmith”的SID不同,因此即使名称相同,也不会将它们视为同一用户。

After you restore on the target server, you need to run 'sp_change_users_login' for the broken users. 在目标服务器上还原后,需要为损坏的用户运行'sp_change_users_login'。

http://www.mssqltips.com/tip.asp?tip=1590 http://www.mssqltips.com/tip.asp?tip=1590

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM