将备份恢复到不同的服务器 - 用户权限
我已将 MS SQL Server 2005 数据库备份并恢复到新服务器。
重新创建登录、用户和用户权限的最佳方法是什么?
在 SQL Server 2000 的企业管理器上,我能够分别编写登录脚本、用户脚本和用户权限脚本。 然后我可以一个接一个地运行,唯一剩下的手动步骤是设置登录密码(出于安全原因,不会编写脚本)
这在 SQL Server 2005 的 Management Studio 中似乎不可能,使得一切都非常繁琐且耗时。 (我最终必须编写整个数据库的脚本,从新数据库中删除所有登录名和用户,运行脚本,然后搜索各种错误消息以查看哪些有效,哪些无效。)
有谁有经验吗?以及对此的建议?
I have backed up and restored a MS SQL Server 2005 database to a new server.
What is the best way of recreating the login, the users, and the user permissions?
On SQL Server 2000's Enterprise Manager I was able to script the logins, script the users and script the user permissions all seperately. I could then run one after the other and the only remaining manual step was to set the login password (which do not script for security reasons)
This does not seem possible in SQL Server 2005's Management Studio, making everything very fiddly and time consuming. (I end up having to script the whole database, delete all logins and users from the new database, run the script, and then trawl through a mixture of error message to see what worked and what didn't.)
Does anyone have any experience and recommendations on this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
最简单的方法是使用 Microsoft 的
sp_help_revlogin
,这是一个存储过程,用于编写所有 SQL Server 登录名、默认值和密码的脚本,并保留相同的 SID。您可以在此知识库文章中找到它:
http://support.microsoft.com/kb/918992
The easiest way to do this is with Microsoft's
sp_help_revlogin
, a stored procedure that scripts all SQL Server logins, defaults and passwords, and keeps the same SIDs.You can find it in this knowledge base article:
http://support.microsoft.com/kb/918992
运行此命令:
这将显示所有孤立用户的列表,例如:
现在在此处执行此脚本例如,每个用户
这解决了我的问题。
Run this:
This will show a list of all Orphaned users, for example:
Now execute this script here for each user, for example
This fixed my problem.
我使用 Red Gate 的 SQL Compare 产品 (http://www.red- gateway.com/products/SQL_Compare/index.htm)。 周围还有其他类似的产品,但我没有理由去寻找一个,因为 SQL Compare 从未让我失望过。
您会发现它的用途远远超出您当前的需求,因为它将帮助同步所有类型的数据库对象,而不仅仅是登录和权限。
I use the SQL Compare product from Red Gate (http://www.red-gate.com/products/SQL_Compare/index.htm). There are other similar products around but I've had no reason to look for one as SQL Compare has never let me down.
You'll find it is useful for a lot more than the your current requirement as it will help synchronize all types of database object, not just login and permissions.