小白求教,mdf文件恢复问题

Vapen 2013-05-29 04:40:54
ldf文件损坏,只有mdf文件。
http://bbs.csdn.net/topics/220057145
用此文的方法一恢复,出现如下报错:


Configuration option 'allow updates' changed from 0 to 1. Run the RECONFIGURE statement to install.
Msg 259, Level 16, State 1, Line 2
Ad hoc updates to system catalogs are not allowed.
Msg 5120, Level 16, State 101, Line 1
Unable to open the physical file "E:\SQL DB\WSS_Content.mdf". Operating system error 5: "5(Access is denied.)".
Msg 945, Level 14, State 2, Line 1
Database 'WSS_Content' cannot be opened due to inaccessible files or insufficient memory or disk space. See the SQL Server errorlog for details.
Msg 5069, Level 16, State 1, Line 1
ALTER DATABASE statement failed.
sp_dboption command failed.
Msg 945, Level 14, State 2, Line 2
Database 'WSS_Content' cannot be opened due to inaccessible files or insufficient memory or disk space. See the SQL Server errorlog for details.
Msg 259, Level 16, State 1, Line 2
Ad hoc updates to system catalogs are not allowed.
Configuration option 'allow updates' changed from 1 to 0. Run the RECONFIGURE statement to install.
Msg 5120, Level 16, State 101, Line 1
Unable to open the physical file "E:\SQL DB\WSS_Content.mdf". Operating system error 5: "5(Access is denied.)".
Msg 945, Level 14, State 2, Line 1
Database 'WSS_Content' cannot be opened due to inaccessible files or insufficient memory or disk space. See the SQL Server errorlog for details.
Msg 5069, Level 16, State 1, Line 1
ALTER DATABASE statement failed.
sp_dboption command failed.
...全文
251 12 打赏 收藏 转发到动态 举报
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
唐诗三百首 2013-05-31
  • 打赏
  • 举报
回复
不知你的recovery状态是怎么来的? 请说一下过程. 一般来讲,恢复最后一个日志文件时须加with recovery选项. 恢复后数据库才是可用状态.
Vapen 2013-05-31
  • 打赏
  • 举报
回复
多谢楼上各位的帮助,鼓捣了N久终于显示在recovery了,但是一直显示正在恢复中。

已经30多个小时了,这个文件270G,这正常么?再大的文件也不需要这么久啊。。。。是不是不正常?

唐诗三百首 2013-05-29
  • 打赏
  • 举报
回复
请用以下案例的方法试试..

-- 建测试数据库u010
create database [u010] on primary 
(name=N'u010', filename=N'D:\SQLDATA\u010.mdf')
 log on 
(name=N'u010_log', filename=N'D:\SQLDATA\u010_log.ldf')
 
-- 卸离数据库
exec dbo.sp_detach_db @dbname=N'u010'
 
-- 确认日志文件存在: File Exists=1
exec dbo.xp_fileexist 'D:\SQLDATA\u010_log.ldf'
 
/*
File Exists File is a Directory Parent Directory Exists
----------- ------------------- -----------------------
1           0                   1
 
(1 row(s) affected)
*/
 
-- 删除日志文件
exec xp_cmdshell 'del D:\SQLDATA\u010_log.ldf'
 
-- 确认日志文件已删除: File Exists=0
exec dbo.xp_fileexist 'D:\SQLDATA\u010_log.ldf'
 
/*
File Exists File is a Directory Parent Directory Exists
----------- ------------------- -----------------------
0           0                   1
 
(1 row(s) affected)
*/
 
-- 缺少日志文件情况下,附加数据库.
create database u010 on 
(filename=N'D:\SQLDATA\u010.mdf') --> 只指定数据文件
for attach
 
-- 结果提示: 新日志文件D:\SQLDATA\u010_log.LDF已创建.
/*
File activation failure. The physical file name "D:\SQLDATA\u010_log.ldf" may be incorrect.
New log file 'D:\SQLDATA\u010_log.LDF' was created.
*/
 
-- 确认数据库附加成功.
select fileid,name,filename
 from u010.dbo.sysfiles
 
/*
fileid name            filename
------ --------------- ----------------------------
1      u010            D:\SQLDATA\u010.mdf      --> 原数据库的数据文件
2      u010_log        D:\SQLDATA\u010_log.LDF  --> 刚自动新建的日志文件
 
(2 row(s) affected)
*/
中关村网名 2013-05-29
  • 打赏
  • 举报
回复
你的数据库是不是还是使用?
USE master;
ALTER DATABASE DBName
SET SINGLE_USER;
运行这个设置成单用户模式,然后把数据分离,分离的时候选 删除连接,再用上面的代码附加试试。
KevinLiu 2013-05-29
  • 打赏
  • 举报
回复
完了,不能附加的,因为你的数据库不是干净的关闭的,还有未完成的事物。(SQL Server重建日志只是重建日志的结构。但是如果有未完成的事物,重建一个空的日志文件会导致数据库数据不一致,所以是不可以重建的) 建议从备份恢复。
Vapen 2013-05-29
  • 打赏
  • 举报
回复


Vapen 2013-05-29
  • 打赏
  • 举报
回复
引用 3 楼 zhengldg 的回复:
权限不够
如图:
把当前用户 的所有操作选项都打上勾吧。


权限已经都给了。

File activation failure. The physical file name "D:\Sharepoint\SharepointDATA\WSS_Content_log.LDF" may be incorrect.
The log cannot be rebuilt because the database was not cleanly shut down.
Msg 1813, Level 16, State 2, Line 1
Could not open new database 'DBNAME'. CREATE DATABASE is aborted.
KevinLiu 2013-05-29
  • 打赏
  • 举报
回复
错误信息是权限不够,你以管理员身份进去ATTACH数据库
中关村网名 2013-05-29
  • 打赏
  • 举报
回复

文件 -》属性-》安全。
中关村网名 2013-05-29
  • 打赏
  • 举报
回复
权限不够
如图:
把当前用户 的所有操作选项都打上勾吧。
Vapen 2013-05-29
  • 打赏
  • 举报
回复
引用 1 楼 zhengldg 的回复:
---只有mdf文件时附加附加数据库
exec sp_attach_single_file_db DBNAME,'E:\ProduceManageSystem_Data.MDF'
使用这个存储过程看看~
Msg 5120, Level 16, State 101, Line 1 Unable to open the physical file "E:\WSS_Content.MDF". Operating system error 5: "5(Access is denied.)".
中关村网名 2013-05-29
  • 打赏
  • 举报
回复
---只有mdf文件时附加附加数据库
exec sp_attach_single_file_db DBNAME,'E:\ProduceManageSystem_Data.MDF'
使用这个存储过程看看~

22,209

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server 疑难问题
社区管理员
  • 疑难问题社区
  • 尘觉
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧