为什么我无法在 Windows 身份验证模式下使用 SQL Express 读取桌面上的 .BAK 文件

发布于 2024-07-08 04:12:47 字数 726 浏览 4 评论 0原文

我试图在 SQL Express 中恢复 .BAK 文件之前执行此 SQL 查询。 最初,我的用户帐户的桌面上有该文件。 我以管理员身份登录。

当我尝试像这样访问桌面上的 .BAK 文件时,

RESTORE FILELISTONLY FROM DISK= 'C:\Documents and Settings\Administrator\Desktop\file.bak'

出现错误。

Msg 3201, Level 16, State 2, Line 1
Cannot open backup device 'C:\Documents and Settings\Administrator\Desktop\file.bak'. Operating system error 5(Access is denied.).
Msg 3013, Level 16, State 1, Line 1
RESTORE FILELIST is terminating abnormally.

但是,当我将 .BAK 文件移动到 C:\temp 并执行此操作时,

RESTORE FILELISTONLY FROM DISK= 'C:\temp\file.bak'

它工作得很好。

我不知道发生了什么事。 有没有办法使用 Windows 身份验证和 SQL Express 来访问桌面上的文件?

I am trying to execute this SQL query prior to restoring a .BAK file in SQL Express. Initially, I had the file on the Desktop of my user account. I am logged in as Administrator.

When I try to access the .BAK file on the desktop like this

RESTORE FILELISTONLY FROM DISK= 'C:\Documents and Settings\Administrator\Desktop\file.bak'

I get an error.

Msg 3201, Level 16, State 2, Line 1
Cannot open backup device 'C:\Documents and Settings\Administrator\Desktop\file.bak'. Operating system error 5(Access is denied.).
Msg 3013, Level 16, State 1, Line 1
RESTORE FILELIST is terminating abnormally.

However, when I move the .BAK file to C:\temp, and execute this

RESTORE FILELISTONLY FROM DISK= 'C:\temp\file.bak'

It works just fine.

I cant figure out what is going on. Is there a way to access files on Desktop using Windows Authentication with SQL Express?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

沒落の蓅哖 2024-07-15 04:12:47

尝试在策略编辑器中向用户本地服务授予对文件夹 C:\Documents and Settings\Administrator\Desktop\ 的读取权限(右键单击该文件夹,然后在“安全性”窗口中)选项卡单击“添加...”,然后单击“高级...|立即查找”

Try granting read permission to Users or LOCAL SERVICE to the folder C:\Documents and Settings\Administrator\Desktop\ in your Policy Editor (right click the folder and in the Security tab click Add... then Advanced...|Find Now

っ左 2024-07-15 04:12:47

当您运行恢复脚本时,它会在 SQL Express 运行所在的服务帐户的上下文中执行。 转到服务管理控制台(或运行 Services.msc)并找到 SQL Express 服务并查看它配置为在哪个帐户下运行,然后查看桌面上文件的权限并确保该帐户具有读取访问权限。

When you are running the restore script, it is executing under the context of the service account that the SQL Express is running under. Go to the Services Management Console ( or run Services.msc) and find the SQL Express service and look at what account it is configured to run under and then look at the permissions of the file on your desktop and make sure that account has read access.

水染的天色ゝ 2024-07-15 04:12:47

在 SQL Server 2008R2 SP1 之后,您不需要转到服务管理控制台(或运行 Services.msc)来查找运行 sql server 服务的帐户。

只需使用下面的代码:

select * from
sys.dm_server_services

SELECT  DSS.servicename,
        DSS.startup_type_desc,
        DSS.status_desc,
        DSS.last_startup_time,
        DSS.service_account,
        DSS.is_clustered,
        DSS.cluster_nodename,
        DSS.filename,
        DSS.startup_type,
        DSS.status,
        DSS.process_id
FROM    sys.dm_server_services AS DSS;

after SQL Server 2008R2 SP1 you don't need to Go to the Services Management Console ( or run Services.msc) to find out the account under which the sql server service is running.

simply use the code below:

select * from
sys.dm_server_services

SELECT  DSS.servicename,
        DSS.startup_type_desc,
        DSS.status_desc,
        DSS.last_startup_time,
        DSS.service_account,
        DSS.is_clustered,
        DSS.cluster_nodename,
        DSS.filename,
        DSS.startup_type,
        DSS.status,
        DSS.process_id
FROM    sys.dm_server_services AS DSS;
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文