Home > Database > Mysql Tutorial > SQLSERVER数据库中的5173错误

SQLSERVER数据库中的5173错误

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-07 15:45:18
Original
1772 people have browsed it

SQLSERVER数据库中的5173错误 昨天同事给你我一个有问题的数据库,叫我修复一下因为客户那边需要这个数据库,这个数据库只有一个mdf文件和一个ldf文件, 当我附加数据库的时候报错,数据库是SQL2005 附上有损坏的数据库文件:http://files.cnblogs.com/lyhab

SQLSERVER数据库中的5173错误

昨天同事给你我一个有问题的数据库,叫我修复一下因为客户那边需要这个数据库,这个数据库只有一个mdf文件和一个ldf文件,

当我附加数据库的时候报错,数据库是SQL2005

附上有损坏的数据库文件:http://files.cnblogs.com/lyhabc/Data.zip

SQLSERVER数据库中的5173错误

 

因为之前在论坛也遇到过,所以按照论坛的方法来解决,结果还是不行

把ldf文件移到别的地方,然后附加的时候使用下面SQL语句重建事务日志文件

我的数据库文件放在C:\Users\Administrator\Desktop\新建文件夹目录下

<span>1</span> <span>USE</span> <span>[</span><span>master</span><span>]</span>
<span>2</span>  <span>GO</span>
<span>3</span>  <span>CREATE</span> <span>DATABASE</span> <span>[</span><span>AdventureWorks2012</span><span>]</span> <span>ON</span> 
<span>4</span> ( FILENAME <span>=</span> N<span>'</span><span>C:\Users\Administrator\Desktop\新建文件夹\GPOSDB.mdf</span><span>'</span><span> )
</span><span>5</span>   <span>FOR</span><span> ATTACH_REBUILD_LOG 
</span><span>6</span> <span>GO</span>
Copy after login

报错内容:

<span>1</span> 文件激活失败。物理文件名称<span>'</span><span>D:\MSSSQL\Data\GPOSDB_log.LDF</span><span>'</span><span>可能不正确。
</span><span>2</span> <span>由于数据库没有完全关闭,无法重新生成日志。
</span><span>3</span> 消息 <span>1813</span>,级别 <span>16</span>,状态 <span>2</span>,第 <span>1</span><span> 行
</span><span>4</span> 无法打开新数据库 <span>'</span><span>GPOSDB</span><span>'</span>。<span>CREATE</span> <span>DATABASE</span> 中止。
Copy after login

 

 


 

我现在按照这篇文章再试一下

http://www.blogjava.net/kent/articles/200991.html

先新建一个GPOSDB的空库,然后停掉SQL服务

SQLSERVER数据库中的5173错误

将刚才生成的数据库的日志文件GPOSDB_log.ldf删除

用要恢复的GPOSDB.mdf文件覆盖刚才生成的数据库数据文件GPOSDB.mdf

然后把有问题的GPOSDB.mdf文件放在D盘,因为我新建的GPOSDB数据库放在D盘

启动SQL服务

文章说会显示数据库置疑,但是我的没有显示置疑

SQLSERVER数据库中的5173错误

设置数据库允许直接操作系统表

在SSMS里输入下面SQL语句

<span>1</span> <span>USE</span><span> master
</span><span>2</span> <span>go</span>
<span>3</span> sp_configure <span>'</span><span>allow updates</span><span>'</span>, <span>1</span> 
<span>4</span> <span>go</span>
<span>5</span> <span>RECONFIGURE</span> <span>WITH</span><span> OVERRIDE
</span><span>6</span> <span>go</span>
Copy after login

设置GPOSDB为紧急修复模式

<span>1</span> <span>ALTER</span> <span>DATABASE</span> <span>[</span><span>GPOSDB</span><span>]</span> <span>SET</span><span> EMERGENCY 
</span><span>2</span> <span>GO</span>
<span>3</span> <span>ALTER</span> <span>DATABASE</span> GPOSDB <span>SET</span><span> SINGLE_USER
</span><span>4</span> <span>GO</span>
<span>5</span> 
<span>6</span> <span>UPDATE</span><span>  sysdatabases
</span><span>7</span> <span>SET</span>     status <span>=</span> <span>-</span><span>32768</span>
<span>8</span> <span>WHERE</span>   dbid <span>=</span> <span>DB_ID</span>(<span>'</span><span>GPOSDB</span><span>'</span><span>)
</span><span>9</span> <span>GO</span>
Copy after login

但是报错

<span>1</span> 消息 <span>259</span>,级别 <span>16</span>,状态 <span>1</span>,第 <span>1</span><span> 行
</span><span>2</span> 不允许对系统目录进行即席更新。
Copy after login

尝试重建日志,但是语法错误,估计那篇文章是SQL2000的

<span>1</span> <span>DBCC</span> rebuild_log(<span>'</span><span>GPOSDB</span><span>'</span>,<span>'</span><span>D:\GPOSDB_log.ldf</span><span>'</span><span>)
</span><span>2</span> <span>GO</span>
Copy after login

<span>1</span> 消息 <span>2526</span>,级别 <span>16</span>,状态 <span>3</span>,第 <span>1</span><span> 行
</span><span>2</span> <span>DBCC</span> 语句错误。请查阅文档以了解正确的 <span>DBCC</span> 语法和选项。
Copy after login

一查果然是

--* DBCC REBUILDLOG
--重建SQL Server 2000事务日志文件

 

其实一开始在步骤“设置数据库允许直接操作系统表” 就怀疑是不是SQL2000的,因为SQL2005或以后已经不能修改系统表了

最后把事务日志文件也放到D盘,然后使用下面的SQL语句来修复还是不行

<span>1</span> <span>ALTER</span> <span>DATABASE</span> <span>[</span><span>GPOSDB</span><span>]</span> <span>SET</span><span> EMERGENCY 
</span><span>2</span> <span>GO</span>
<span>3</span> <span>ALTER</span> <span>DATABASE</span> GPOSDB <span>SET</span><span> SINGLE_USER
</span><span>4</span> <span>GO</span>
<span>5</span> 
<span>6</span> <span>DBCC</span><span> CheckDB (GPOSDB, REPAIR_ALLOW_DATA_LOSS)
</span><span>7</span> <span>GO</span>
Copy after login

 

<span> 1</span> 消息 <span>5173</span>,级别 <span>16</span>,状态 <span>1</span>,第 <span>2</span><span> 行
</span><span> 2</span> <span>一个或多个文件与数据库的主文件不匹配。如果是尝试附加数据库,请使用正确的文件重试该操作。如果这是现有数据库,则文件可能已损坏,应该从备份进行还原。
</span><span> 3</span> 日志文件 <span>'</span><span>D:\GPOSDB_log.ldf</span><span>'</span><span> 与主文件不匹配。该文件可能来自另一数据库,或者可能以前重新生成了日志。
</span><span> 4</span> 消息 <span>5123</span>,级别 <span>16</span>,状态 <span>1</span>,第 <span>2</span><span> 行
</span><span> 5</span> 尝试打开或创建物理文件 <span>'</span><span>D:\MSSSQL\Data\GPOSDB_log.LDF</span><span>'</span> 时,<span>CREATE</span> <span>FILE</span> 遇到操作系统错误 <span>3</span><span>(系统找不到指定的路径。)。
</span><span> 6</span> 消息 <span>5024</span>,级别 <span>16</span>,状态 <span>2</span>,第 <span>2</span><span> 行
</span><span> 7</span> <span>在 sysfiles1 中找不到主日志文件所对应的条目。无法重建日志。
</span><span> 8</span> 消息 <span>5028</span>,级别 <span>16</span>,状态 <span>2</span>,第 <span>2</span><span> 行
</span><span> 9</span> <span>系统无法激活足够的数据库来重建日志。
</span><span>10</span> GPOSDB的 <span>DBCC</span><span> 结果。
</span><span>11</span> CHECKDB 在数据库 <span>'</span><span>GPOSDB</span><span>'</span> 中发现 <span>0</span> 个分配错误和 <span>0</span><span> 个一致性错误。
</span><span>12</span> 消息 <span>7909</span>,级别 <span>20</span>,状态 <span>1</span>,第 <span>2</span><span> 行
</span><span>13</span> 紧急模式修复失败。您必须从备份中还原。
Copy after login

 SQLSERVER数据库中的5173错误


 

最后我还是放弃了~~   希望知道怎麽解决的大侠可以给我帮助,谢谢了o(∩_∩)o 

 

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
Problem with tp6 connecting to sqlserver database
From 1970-01-01 08:00:00
0
0
0
Unable to connect to SQL Server in Laravel
From 1970-01-01 08:00:00
0
0
0
Methods of parsing MYD, MYI, and FRM files
From 1970-01-01 08:00:00
0
0
0
SQLSTATE: User login failed
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template