启动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* 权限,然后重新测试。

    例如,如果为服务帐户分配了“拒绝作为服务登录”以及“作为服务SeServiceLogonRightSeDenyServiceLogonRight登录”,请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 配置管理器服务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。 所需结果 为 true。 如果为 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).

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

  • 针对特定 Windows 服务器将SQL Server启动配置为延迟启动,这可确保其他 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