啟動 SQL Server 服務時發生錯誤 1069

原始產品版本:SQL Server
原始 KB 編號: 282254

Summary

錯誤 1069,「服務因登入失敗而未啟動」,發生在 SQL Server 或 SQL Server Agent 服務無法使用其設定的服務帳號登入時。 本文說明當系統事件日誌條目顯示服務控制管理器事件 ID 7041 或事件 ID 7038 時,如何解決錯誤 1069。 原因包括缺少「以服務方式登入」的權限、帳號被停用或鎖定、密碼過期或錯誤,以及啟動時無法連線的網域。

症狀

當您嘗試重新啟動Microsoft SQL Server 或 SQL Server Agent 時,服務不會啟動,而且您會收到下列錯誤訊息,視您嘗試啟動服務的方式而定:

  • 透過使用服務小工具:

    Windows 無法在本機計算機上啟動 SQL Server 服務。
    錯誤 1069:服務因為登入失敗而未啟動。

  • 使用命令提示字元:

    發生系統錯誤 1069。
    服務因為登入失敗而未啟動。

你可能會在系統事件日誌中發現事件 ID 7041 或 7038 的訊息。

原因

發生此問題的原因是服務帳戶本身有問題,或目前儲存於服務帳戶的資訊有問題。

哪個處理方式是針對你的事件 ID 的

請使用系統事件日誌中的事件 ID 與錯誤文字來選擇解決方法:

事件識別碼 事件中的錯誤文字 Resolution
7041 登入失敗︰未授與使用者在電腦上所要求的登入類型。 事件編號 7041 的解決方式
7038 此用戶無法登入,因為此帳戶目前已停用。 帳號已停用
7038 登入前必須更改使用者的密碼。 密碼必須更改
7038 使用者名稱或密碼不正確。 密碼或 gMSA 旗標不正確
7038 指定的帳戶目前已鎖定,可能無法登入。 帳戶遭到鎖定
7038 指定的網域不存在或連不上。 無法連線到網域

事件標識碼 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. 啟動 本機安全性原則 嵌入式管理單元(secpol.msc)。

  2. 展開「本地政策」,然後選擇「使用者權限指派」。

  3. 請依照 Windows 權限與權利中的指示,確認服務帳號已獲得所需的使用者權限。 手動指派任何缺少的權限。

  4. 檢查該服務帳號是否被指派任何 拒絕 使用者權限。 移除 SQL Server 服務帳號的所有拒絕使用者權限,然後再重新測試。

    例如,如果服務帳號同時被指派 拒絕以服務方式登入SeDenyServiceLogonRight 和 以服務方式登入SeServiceLogonRight,則撤銷該帳號的SeDenyServiceLogonRight登入權限並重新啟動 SQL Server。

事件標識碼 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>\<SQLServiceAccount> cmd
      
  2. 如果命令成功,請在 SQL Server 組態管理員、服務、SQL Server 服務 和 此帳戶 中仔細輸入相同的認證。

  3. 如果指令失敗並回報相同問題,請重設 Windows 登入的密碼。

  4. 如果 SQL Server 啟動帳戶是電腦上的本機用戶帳戶,請開啟 計算機管理(compmgmt.msc),然後重設本機用戶的密碼。

  5. 如果 SQL Server 啟動帳戶是 Windows 網域帳戶,請開啟 Active Directory 使用者和電腦,然後更新在 使用者 底下之帳戶的密碼。 更新認證之後,返回 SQL Server 組態管理員、Services、SQL Server,然後輸入相同的認證。

  6. 重新啟動 SQL Server 服務。

    若要在 SQL Server 主電腦上的 SQL Server 服務帳戶中輸入正確的密碼,請遵循 SCM 服務 - 變更所使用帳戶的密碼 中的程序。

案例 2:gMSA IsManagedAccount 旗標設定不當

如果你使用群組管理服務帳號(gMSA)來執行 SQL Server 服務,且IsManagedAccount該服務的標誌設為 false,一旦快取的祕密失效,你可能會收到服務控制管理員事件 ID 7038。

若要找出並解決問題,請遵循下列步驟:

  1. 確認您使用的帳戶是 gMSA 帳戶。 只有在確認 gMSA 之後,才繼續進行。

    • 如果以下指令成功對該帳號生效,表示你使用的是 gMSA 帳號。
    • 如果使用 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. 嘗試再次啟動服務。

關於更多針對 gMSA 帳戶的故障排除步驟,請參閱《用 gMSA 排解 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 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 組態管理員、Services 和 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 Server 2022 起,這一直是 SQL 安裝程式中的預設組態。

  • 如果延遲啟動選項無法解決你的情況中的問題,請更改 SQL Server 服務的復原選項。 將 重新啟動服務 指定為失敗選項的動作。 透過熟悉的服務控制管理器介面,從管理工具的服務小程式中執行此選項。

    • 不建議針對 SQL 故障轉移叢集實例 (FCI) 或可用性群組 (AG) 使用此選項,因為設定這可能會在自動故障轉移案例期間造成延遲。
  • 若上述兩種選項皆不可行,請在提升權限的命令列主控台中執行下列命令,將 SQL Server 服務設定為相依於 Netlogon 服務:

    sc config <YourSQLServiceName> depend=keyiso/netlogon
    

    SQL Server 具名實例 SQLPROD 的範例:

    sc config MSSQL$SQLPROD depend=keyiso/netlogon