启动 SQL Server 服务时出现错误 1069

启动 SQL Server 服务时收到错误 1069,这会导致登录失败。 本文提供错误 1069 相关事件的解决方法。

原始产品版本:SQL Server
原始 KB 数: 282254

现象

尝试重启Microsoft SQL Server 或SQL Server 代理时,服务不会启动,并且你会收到以下错误消息,具体取决于尝试启动服务的方式:

  • 通过使用服务小程序:

    Windows 无法在本地计算机上启动 SQL Server 服务。
    错误 1069:由于登录失败,服务未启动。

  • 使用命令提示符:

    系统错误 1069 已发生。
    由于登录失败,服务未启动。

可以在系统事件日志中找到事件 ID 为 7041 或 7038 的消息。

原因

出现此问题的原因是服务帐户本身存在问题,或者当前为服务帐户保存的信息。

事件 ID 7041 的解决方法

系统事件日志中事件 ID 为 7041 的条目可能包含以下错误消息:

登录失败:未授予用户在此计算机上的请求登录类型。

事件日志中的完整消息条目如下所示:

Log Name:      System
Source:        Service Control Manager
Date:          <Datetime>
Event ID:      7041
Task Category: None
Level:         Error
Keywords:      Classic
User:          N/A
Computer:      <Server name>
Description:
The MSSQLSERVER service was unable to log on as NT Service\MSSQLSERVER with the currently configured password due to the following error:
Logon failure: the user has not been granted the requested logon type at this computer.

Service: MSSQLSERVER  
Domain and account: <AccountName>

This service account does not have the required user right "Log on as a service."

User Action

Assign "Log on as a service" to the service account on this computer. You can use Local Security Settings (Secpol.msc) to do this.
If this computer is a node in a cluster, check that this user right is assigned to the Cluster service account on all nodes in the cluster.

If you have already assigned this user right to the service account, and the user right appears to be removed,
check with your domain administrator to find out if a Group Policy object associated with this node might be removing the right.

若要解决此问题,请检查向 SQL Server 服务帐户分配了哪些用户权限。

  1. 启动 本地安全策略 (Start -> Secpol.msc)。

  2. 展开 “本地策略 ”,然后选择“ 用户权限分配”。

  3. 按照 Windows 特权和权限中的说明,验证是否已将所需的用户权限分配给服务帐户。 手动分配任何缺失的权限。

  4. 检查服务帐户是否已分配任何 拒绝* 权限。 从 SQL 服务帐户中删除任何 Deny* 权限,然后重新测试。

    例如,如果为服务帐户分配了拒绝以服务SeDenyServiceLogonRight身份登录以及以SeServiceLogonRight服务身份登录,请撤销SeDenyServiceLogonRight登录权限并重启 SQL Server。

事件 ID 7038 的解决方法

在与事件 ID 7038 相关的日志条目中,你可能会发现以下错误消息:

此用户无法登录,因为此帐户当前已禁用

事件日志中的完整消息条目如下所示:

Log Name:      System
Source:        Service Control Manager
Date:          <Datetime>
Event ID:      7038
Task Category: None
Level:         Error
Keywords:      Classic
User:          N/A
Computer:      <Server name>
Description:
The MSSQLSERVER service was unable to log on as .\sqlsrvlogin with the currently configured password due to the following error:
This user can't sign in because this account is currently disabled.

To ensure that the service is configured properly, use the Services snap-in in Microsoft Management Console (MMC).

若要解决此问题,请根据方案使用以下方法之一:

  • 如果 SQL Server 启动帐户是计算机上的本地用户帐户,请打开 *计算机管理(compmgmt.msc),并检查本地用户和组中是否禁用了服务帐户。 如果已禁用,请启用帐户并重启 SQL Server 服务。

  • 如果 SQL Server 启动帐户是 Windows 域帐户,请检查该帐户是否在Active Directory 用户和计算机禁用。 如果已禁用,请启用帐户并重启 SQL Server 服务。

登录前必须更改用户的密码

事件日志中的完整消息条目如下所示:

Log Name:      System
Source:        Service Control Manager
Date:          <Datetime>
Event ID:      7038
Task Category: None
Level:         Error
Keywords:      Classic
User:          N/A
Computer:      <Server name>
Description:
The MSSQLSERVER service was unable to log on as .\sqlsrvlogin with the currently configured password due to the following error:
The user's password must be changed before signing in.

To ensure that the service is configured properly, use the Services snap-in in Microsoft Management Console (MMC).

若要解决此问题,请根据方案使用以下方法之一:

  • 如果 SQL Server 启动帐户是计算机上的本地用户帐户:

    1. 打开 计算机管理 (compmgmt.msc)。
    2. 选择“本地用户和组”,然后选择“用户以找到该帐户。
    3. 双击用户帐户以打开其 属性
    4. 清除 用户必须在 SQL Server 启动帐户的下一个登录 属性处更改密码,然后按 “确定”。
    5. 重启 SQL Server 服务。
  • 如果 SQL Server 启动帐户是 Windows 域帐户:

    1. 在域控制器上打开Active Directory 用户和计算机
    2. 在正确的域下选择“ 用户 ”。
    3. 双击用作 SQL Server 服务帐户的域帐户以打开其 属性
    4. 转到“帐户”选项卡,检查用户下次登录时是否必须更改密码。 如果启用此选项,请清除此选项或以交互方式登录到 Windows 客户端计算机,然后设置新密码。
    5. 如果更改了密码,请使用 SQL Server 配置管理器 工具更新 SQL Server 服务的新密码。

用户名或密码不正确

对于不正确的密码问题,事件日志中的完整消息条目如下所示:

Log Name:      System
Source:        Service Control Manager
Date:          <Datetime>
Event ID:      7038
Task Category: None
Level:         Error
Keywords:      Classic
User:          N/A
Computer:      <Server name>
Description:
The MSSQLSERVER service was unable to log on as .\sqlsrvlogin with the currently configured password due to the following error:
The user name or password is incorrect.

To ensure that the service is configured properly, use the Services snap-in in Microsoft Management Console (MMC).

若要解决此问题,请执行以下步骤:

方案 1:密码不正确

错误消息条目指示当前的登录名或密码集不正确。 若要验证并解决问题,请执行以下步骤:

  1. runas使用此选项测试服务帐户凭据:

    1. 打开 Windows 命令提示符。

    2. 运行以下命令:

      runas /user:<localmachine>\<SQLSerivceAccount> cmd
      
  2. 如果命令成功,请在 SQL Server 配置管理器、Services、SQL Server 服务和此帐户仔细键入相同的凭据。

  3. 如果命令失败并报告相同的问题,则必须重置 Windows 登录的密码。

  4. 如果 SQL Server 启动帐户是计算机上的本地用户帐户,请打开 计算机管理 (compmgmt.msc),并重置本地用户的密码。

  5. 如果 SQL Server 启动帐户是 Windows 域帐户,请打开Active Directory 用户和计算机,然后在“用户”下更新帐户的密码。 更新凭据后,返回到SQL Server 配置管理器服务SQL Server 并输入相同的凭据。

  6. 重新启动 SQL Server 服务。

    若要在 SQL Server 主计算机上的 SQL Server 服务帐户中键入正确的密码,请遵循 SCM 服务中的过程 - 更改使用的帐户的密码。

方案 2:gMSA IsManagedAccount 标志设置不当

如果使用组托管服务帐户(gMSA)帐户来运行 SQL Server 服务,并且 IsManagedAccount 给定服务的标志设置为 false,则缓存机密无效后,可能会立即收到服务控制管理器事件 ID 7038。

若要识别并解决问题,请执行以下步骤:

  1. 验证所使用的帐户是否为 gMSA 帐户。 仅在确认 gMSA 后继续。

    • 如果以下命令针对帐户成功,则使用 gMSG 帐户。
    • 如果失败, Cannot find an object with identity: 'account'则服务帐户不是 gMSA 帐户。
    Get-ADServiceAccount -Identity 'yourGmsaName' -Properties PasswordLastSet
    

    有关详细信息,请参阅 检查 gMSA 帐户

  2. 在命令提示符运行以下命令,并检查其状态IsManagedAccount。 所需的结果是正确的。 如果为 false,请继续操作。

    sc qmanagedaccount <YourSQLServiceName>
    

    SQL Server 命名实例 SQLPROD 的示例:

    sc qmanagedaccount MSSQL$SQLPROD
    
  3. 根据需要将标志设置为 true。

    sc managedaccount <YourSQLServiceName> TRUE
    

    SQL Server 命名实例 SQLPROD 的示例:

    sc managedaccount MSSQL$SQLPROD TRUE
    
  4. 尝试再次启动服务。

引用的帐户当前已锁定,可能无法登录

事件日志中的完整消息条目如下所示:

Log Name:      System
Source:        Service Control Manager
Date:          <Datetime>
Event ID:      7038
Task Category: None
Level:         Error
Keywords:      Classic
User:          N/A
Computer:      <Server name>
Description:
The MSSQLSERVER service was unable to log on as .\sqlsrvlogin with the currently configured password due to the following error:
The referenced account is currently locked out and may not be logged on to.

To ensure that the service is configured properly, use the Services snap-in in Microsoft Management Console (MMC).

若要解决此问题,请根据方案使用以下方法之一:

  • 如果 SQL Server 启动帐户是计算机上的本地用户帐户:

    1. 打开 计算机管理 (compmgmt.msc),并转到 本地用户和组。 然后选择“ 用户”。
    2. 清除“本地用户和组”下的 SQL Server 启动帐户的“锁定”复选框,然后选择“确定”。
    3. 重启 SQL Server 服务。
  • 如果 SQL Server 启动帐户是 Windows 域帐户:

    1. 在域控制器上打开Active Directory 用户和计算机
    2. 在“用户”下,双击“SQL Server 启动帐户”,然后转到“帐户选项卡。
    3. 检查帐户是否已标记为已锁定。
    4. 如果帐户已锁定,请选择“解锁帐户”框,然后选择“确定,设置强密码。
    5. 然后在 SQL Server 配置管理器服务和 SQL Server 中使用 SQL Server 服务帐户配置的相同凭据。
    6. 重新启动 SQL Server 服务。

指定的域不存在或无法联系

事件日志中的完整消息条目如下所示:

Log Name:      System
Source:        Service Control Manager
Date:          <Datetime>
Event ID:      7038
Task Category: None
Level:         Error
Keywords:      Classic
User:          N/A
Computer:      <Server name>
Description:
The MSSQLSERVER service was unable to log on as xxx with the currently configured password due to the following error:
The specified domain either does not exist or could not be contacted.

To ensure that the service is configured properly, use the Services snap-in in Microsoft Management Console (MMC).

若要解决此问题,请根据方案使用以下方法之一:

  • 将 SQL Server 启动配置为特定 Windows 服务器的延迟启动,这可确保其他 Windows 服务(如 NetLogon 先完成),SQL Server 启动时不会出现问题。 这是 SQL 安装程序从 SQL Server 2022 开始的默认配置。

  • 如果延迟的启动选项无法解决方案的问题,另一种选择是更改 SQL Server 服务的恢复选项。 将“重启服务”指定为故障选项的操作。 你可以使用熟悉的“服务控制管理器”界面从“管理工具”的“服务”小程序执行此选项。

    • 不建议对 SQL 故障转移群集实例(FCI)或可用性组(AG)使用此选项,因为设置可能会导致自动故障转移方案出现延迟。
  • 如果上述两个选项都不可行,则可以在提升的命令行控制台中使用以下命令将 SQL Server 服务配置为依赖于 NETLOGON 服务:

    sc config <YourSQLServiceName> depend=keyiso/netlogon
    

    SQL Server 命名实例 SQLPROD 的示例:

    sc config MSSQL$SQLPROD depend=keyiso/netlogon