如何使用密码将登录从2008R2转移到2014?


12

我已经尝试过Tasks>,Generate Scripts...并在“高级脚本选项”中设置了“脚本登录名”,但在输出中得到了此信息:

/* For security reasons the login is created disabled and with a random password. */

有没有一种简单的方法可以用密码对这些登录进行脚本编写,或者可以通过其他方法将登录从2008R2实例传输到2014实例?


4
sqlsoldier.com/wp/sqlserver/…(只需忽略镜像引用-这可在任何实例之间移动任何登录名)。
亚伦·伯特兰

乍一看,@ Aaron非常好,谢谢。
杰克说请尝试topanswers.xyz 2014年

1
@Aaron我最终使用它,基本上是一样的东西。感谢您指出正确的方向。
杰克说请尝试topanswers.xyz 2014年

Answers:


8

为了传输登录名,您将需要使用sp_help_revlogin脚本和过程。这将允许您转移登录名,并将密码从实例转移到另一个实例。


我去过那个页面,但我显然不明白。方法3说“创建一个具有空白密码的登录脚本”,所以大概不是吗?
杰克说请尝试topanswers.xyz 2014年

1
@JackDouglas不确定该短语的含义,但是您只需要在源服务器上创建这两个存储过程,最后只需执行sp_help_revlogin,从SSMS中获取其输出并在新服务器上执行即可。您将使用正确的密码重新创建登录名。
玛丽安2014年

我已经在SQL 2014上对此进行了测试,但无法正常工作,直到sql 2012为止,该方法才有效。还在support.microsoft.com/kb/91899中
Iman Abidi

我测试过,sp_help_revlogin但在SQL 2014 SP1 CU1(12.0.4416)中不起作用。此知识库文章中提到,它的工作,直到SQL Server 2012的
伊曼Abidi

6

我等不及每个人都了解这一点:

https://dbatools.io/

https://blog.netnerds.net/2016/06/its-2016-why-is-sp_help_revlogin-a-thing/

简而言之:安装dbatools Powershell脚本。

现在,您拥有了一套很棒的命令,它们不仅可以复制SQL用户,密码,权限等,还可以复制其他用户。而且还有详尽的命令集,用于复制数据库,作业甚至整个实例:D

用法示例:

Copy-DbaLogin -Source sqlsvr2000 -Destination newsql2016

要么:

Export-DbaLogin -SqlServer sql2005 -FileName C:\temp\sql2005-logins.sql

干杯!



0

是的,您可以使用各种模块通过Powershell:

1-使用DBATools:打开Powershell

<# Install-Module dbatools#> #only if not installed

<# Load the module#>

Import-module dbatools

export-dbalogin -SqlInstance ServerName f:\floginsdba.txt

2-使用SQLSERVER模块:

<# Install-Module sqlserver#> #only if not installed

<# Load the module#>

Import-module sqlserver

cd sqlserver:\serverA\default\logins   # replace the default with any named Inst

dir | %{$_.script()}                   

<# For security, it will create disabled  logins and hashed passwords for sql logins.#>

让我知道您是否需要任何帮助。

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.