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

本文可帮助你解决为 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

原因

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

  • 更改数据库和日志文件的存储驱动器,并丢失以更新默认数据和日志位置。
  • 在“数据目录”选项卡中初始安装期间,默认数据或日志路径配置错误(请参阅数据库引擎配置 - 数据目录页)。
  • SQL Server Management Studio 中数据库设置的默认数据或日志路径配置错误(请参阅查看或更改数据和日志文件的默认位置)。

解决方法

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

步骤 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 或累积更新

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

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

参考

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