安装累积更新或 Service Pack 时出现注册表中的数据或日志目录无效的错误SQL Server

本文可帮助你解决为SQL Server实例安装累积更新或 Service Pack 时出现的问题。

原始产品版本:SQL Server
原始 KB 编号: 2565113

症状

为SQL Server实例安装累积更新或 Service Pack 时,安装过程可能会失败,并显示以下错误消息之一:

The User Data directory in the registry is not valid. Verify DefaultData key under the instance hive points to a valid directory.
Error code: 0x851A0043
The User Log directory in the registry is not valid. Verify DefaultLog key under the instance hive points to a valid directory.
Error code: 0x851A0044
Error installing SQL Server Database Engine Services Instance Features. The Database Engine system data directory in the registry is not valid.

出现问题时,SQL Server安装程序日志文件 Summary.txt 包含以下消息之一:

Detailed results:
  Feature:                       Database Engine Services
  Status:                        Failed: see logs for details
  Reason for failure:            An error occurred during the setup process of the feature.
  Next Step:                     Use the following information to resolve the error, and then try the setup process again.
  Component name:                SQL Server Database Engine Services Instance Features
  Component error code:          0x851A0043
  Error description:             The User Data directory in the registry is not valid. Verify DefaultData key under the instance hive points to a valid directory.
  Error help link:               http://go.microsoft.com/fwlink?LinkId=20476&ProdName=Microsoft+SQL+Server&EvtSrc=setup.rll&EvtID=50000&ProdVer=11.0.7001.0&EvtType=0xD8FB5EBA%400x97A656BB%401306%4067&EvtType=0xD8FB5EBA%400x97A656BB%401306%4067
Detailed results:
  Feature:                       Database Engine Services
  Status:                        Failed: see logs for details
  Reason for failure:            An error occurred during the setup process of the feature.
  Next Step:                     Use the following information to resolve the error, and then try the setup process again.
  Component name:                SQL Server Database Engine Services Instance Features
  Component error code:          0x851A0044
  Error description:             The User Log directory in the registry is not valid. Verify DefaultLog key under the instance hive points to a valid directory.
  Error help link:               http://go.microsoft.com/fwlink?LinkId=20476&ProdName=Microsoft+SQL+Server&EvtSrc=setup.rll&EvtID=50000&ProdVer=11.0.7001.0&EvtType=0xD8FB5EBA%400x97A656BB%401306%4068&EvtType=0xD8FB5EBA%400x97A656BB%401306%4068

原因

当数据库的新数据或日志文件的默认位置指向无效位置时,会出现此问题。 导致此问题的常见方案包括:

解决方案

使用以下过程来解决问题。

步骤 1:更正默认数据和日志目录的有效文件夹路径

可以使用 SQL Server Management Studio 或注册表编辑器将默认数据目录和日志目录值设置为有效的文件夹路径。

方法 1:使用 SQL Server Management Studio (SSMS) 和SQL Server 配置管理器
  1. 在 SSMS 中,打开对象资源管理器,右键单击服务器实例并选择“属性”。
  2. 在左侧面板中,选择“ 数据库设置” 页。
  3. “数据库默认位置”中,查看新数据文件和新日志文件的当前默认位置。
  4. 若要更改默认位置,请在 “数据 ”或“ 日志 ”字段中输入新的默认路径名,或选择“浏览”按钮以查找并选择路径名。
  5. 打开SQL Server 配置管理器并选择“SQL Server服务”。
  6. 双击实例,然后选择“ 高级 ”选项卡。
  7. 查看 “数据路径” 属性,并查看该值是否正确。 该值灰显,无法在此处进行修改。
  8. 如果值不正确,请使用 方法 2 将其更新为正确的路径。
方法 2:使用注册表编辑器

重要

此部分(或称方法或任务)介绍了修改注册表的步骤。 对注册表修改不当可能会导致严重问题。 因此,请务必严格按照这些步骤操作。 为了加强保护,应先备份注册表,再进行修改。 如果出现问题,可以还原注册表。 有关如何备份和还原注册表的详细信息,请参阅如何备份和还原 Windows 中的注册表

  1. 从命令行启动注册表编辑器 (Regedit.exe) 。

  2. 找到并选择注册表子项 HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server\MSSQL{nn}.Instance\MSSQLServer

    注意

    在此注册表子项中, MSSQL{nn}.Instance 表示系统的相应值。 若要获取此值,请找到并选择注册表子项: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server\Instance Names\SQL\

  3. 在右侧面板中,选择 DefaultData 注册表项,如果它指向不正确的位置,则输入有效路径。

  4. 在右侧面板中,选择 DefaultLog 注册表项,如果它指向不正确的位置,则输入有效路径。

  5. 找到并选择注册表子项 HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server\MSSQL{nn}.Instance\Setup

  6. 在右侧面板中,选择 SQLDataRoot 注册表项,如果它指向不正确的位置,则输入有效路径。

步骤 2:重试安装 Service Pack 或累积更新

更正受影响实例的数据和日志路径后,可以重试安装。

安装程序可能显示实例已升级,并且可能不允许仅选择数据库服务组件。 需要为该实例选择所有功能,以便安装程序继续。

References

查看和读取SQL Server安装程序日志文件