[英]Unable to open the file .mdf/.ldf. Operating system error 5: 5“(Access is denied.)” - Trying to replace .mdf/.ldf file with new one
I have the ability to move .mdf
/ .ldf
files at will from the default \DATA
folder location.我可以从默认的
\DATA
文件夹位置随意移动.mdf
/ .ldf
文件。 I can set the database online and offline whenever I move these files manually.每当我手动移动这些文件时,我都可以将数据库设置为联机和脱机。
We get a new set of .mdf
/ .ldf
file every month to replace the one that we have.我们每个月都会获得一组新的
.mdf
/ .ldf
文件来替换我们拥有的文件。 I am trying to automate this process with SSIS.我正在尝试使用 SSIS 自动化这个过程。 I have managed to create a package that will handle replacing the old
.mdf
/ .ldf
files with the new ones.我设法创建了一个 package 来处理用新文件替换旧的
.mdf
/ .ldf
文件。
BUT!但!
The SQL task to turn on the database with the new .mdf
/ .ldf
files does not run.使用新的
.mdf
/ .ldf
文件打开数据库的 SQL 任务未运行。
I get this error:我收到此错误:
Error: 0xC002F210 at Take Sandbox Online, Execute SQL Task: Executing the query "ALTER DATABASE Sandbox SET ONLINE" failed with the following error: "Unable to open the physical file "C:\Program Files\Microsoft SQL Server\MSSQL13.SERVER\MSSQL\DATA\SANDBOX.mdf". Operating system error 5: "5(Access is denied.)".
错误:0xC002F210 at Take Sandbox Online, Execute SQL 任务:执行查询“ALTER DATABASE Sandbox SET ONLINE”失败,出现以下错误:“无法打开物理文件”C:\Program Files\Microsoft Z9778840A0100CB30C982876741B0B5SSERVER5 MSSQL\DATA\SANDBOX.mdf”。操作系统错误 5:“5(拒绝访问。)”。
Unable to open the physical file "C:\Program Files\Microsoft SQL Server\MSSQL13.SERVER\MSSQL\DATA\SANDBOX_LOG.ldf".
无法打开物理文件“C:\Program Files\Microsoft SQL Server\MSSQL13.SERVER\MSSQL\DATA\SANDBOX_LOG.ldf”。 Operating system error 5: "5(Access is denied.)".
操作系统错误 5:“5(拒绝访问。)”。
I am able to do this process manually, but for some reason SSIS is not able to turn the database back on with a SQL Task.我可以手动执行此过程,但由于某种原因 SSIS 无法使用 SQL 任务重新打开数据库。 I clearly have permissions to perform this task, but I am ignorant of how running through SSIS would be an issue.
我显然有权执行此任务,但我不知道如何通过 SSIS 运行将是一个问题。
Please help!请帮忙!
Thank you谢谢
SQL Server uses a service account, usually called NT SERVICE\MSSQLSERVER
, which needs to have permissions on the mdf/ldf files. SQL 服务器使用服务帐户,通常称为
NT SERVICE\MSSQLSERVER
,需要对 mdf/ldf 文件具有权限。
Right click the files, click properties / security /edit / add, and add the account to permissions.右键单击文件,单击属性/安全/编辑/添加,然后将帐户添加到权限。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.