

本文為英文版的機器翻譯版本，如內容有任何歧義或不一致之處，概以英文版為準。

# 升級 Amazon Aurora MySQL 資料庫叢集
<a name="AuroraMySQL.Updates.Upgrading"></a><a name="mysql_upgrade"></a>

 您可以升級 Aurora MySQL 資料庫叢集以取得錯誤修正、新的 Aurora MySQL 功能，或變更為全新版本的基礎資料庫引擎。下列各節說明如何執行此操作。

**注意**  
 您進行的升級類型取決於您可以為叢集提供多少停機時間、計劃進行多少驗證測試、特定錯誤修正或新功能對您的使用案例有多重要，以及您是否計劃經常進行小型升級，還是偶爾會略過若干中間版本。針對每次升級，您可以變更叢集的主要版本、次要版本和修補程式層級。如果您不熟悉 Aurora MySQL 主要版本、次要版本和修補程式層級之間的區別，可以在此閱讀背景資訊 [檢查 Aurora MySQL 版本編號](AuroraMySQL.Updates.Versions.md)。

**提示**  
您可以使用藍/綠部署，將資料庫叢集升級所需的停機時間降至最低。如需更多詳細資訊，請參閱 [使用 Amazon Aurora 藍/綠部署進行資料庫更新](blue-green-deployments.md)。

**Topics**
+ [升級 Aurora MySQL 資料庫叢集的次要版本或修補程式層級](AuroraMySQL.Updates.Patching.md)
+ [升級 Amazon Aurora MySQL 資料庫叢集的主要版本](AuroraMySQL.Updates.MajorVersionUpgrade.md)

# 升級 Aurora MySQL 資料庫叢集的次要版本或修補程式層級
<a name="AuroraMySQL.Updates.Patching"></a>

 您可以使用下列方法來升級資料庫叢集的次要版本或修補資料庫叢集：
+ [透過修改引擎版本升級 Aurora MySQL](AuroraMySQL.Updates.Patching.ModifyEngineVersion.md) (適用於 Aurora MySQL 第 2 版和第 3 版)
+ [啟用次要 Aurora MySQL 版本之間的自動升級](AuroraMySQL.Updates.AMVU.md)

 如需零停機時間修補如何在升級程序期間減少中斷的相關資訊，請參閱[使用零停機時間修補](AuroraMySQL.Updates.ZDP.md)。

如需為 Aurora MySQL 資料庫叢集執行次要版本升級的相關資訊，請參閱下列主題。

**Topics**
+ [執行次要版本升級之前](#USER_UpgradeDBInstance.PostgreSQL.BeforeMinor)
+ [Aurora MySQL 的次要版本升級預先檢查](#AuroraMySQL.minor-upgrade-prechecks)
+ [透過修改引擎版本升級 Aurora MySQL](AuroraMySQL.Updates.Patching.ModifyEngineVersion.md)
+ [啟用次要 Aurora MySQL 版本之間的自動升級](AuroraMySQL.Updates.AMVU.md)
+ [使用零停機時間修補](AuroraMySQL.Updates.ZDP.md)
+ [替代藍/綠升級技術](#AuroraMySQL.UpgradingMinor.BlueGreen)

## 執行次要版本升級之前
<a name="USER_UpgradeDBInstance.PostgreSQL.BeforeMinor"></a>

建議您執行下列動作，以減少次要版本升級期間的停機時間：
+ Aurora 資料庫叢集維護應在低流量期間執行。使用 Performance Insights 來識別這些時段，以正確設定維護時段。如需 Performance Insights 的詳細資訊，請參閱[在 Amazon RDS 上使用 Performance Insights 監控資料庫負載](https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/USER_PerfInsights.html)。如需資料庫叢集維護時段的詳細資訊，請參閱 [調整偏好的資料庫叢集維護時段](USER_UpgradeDBInstance.Maintenance.md#AdjustingTheMaintenanceWindow.Aurora)。
+ 最佳實務是支援指數退避和抖動 AWS SDKs。如需詳細資訊，請參閱[指數退避和抖動](https://aws.amazon.com/blogs/architecture/exponential-backoff-and-jitter/)。

## Aurora MySQL 的次要版本升級預先檢查
<a name="AuroraMySQL.minor-upgrade-prechecks"></a>

當您開始次要版本升級時，Amazon Aurora 會自動執行預先檢查。

系統會強制執行這些前置檢查，您無法選擇略過這些檢查。前置檢查提供以下優勢：
+ 升級期間可避免非預期的停機時間。
+ 出現不相容情況時，Amazon Aurora 即會防止系統進行升級，並提供相關日誌讓您了解。如此，您就可以使用這些日誌來減少不相容情況，為資料庫做好升級的準備。如需移除不相容的詳細資訊，請參閱 MySQL 文件中的[準備您的安裝進行升級](https://dev.mysql.com/doc/refman/8.0/en/upgrade-prerequisites.html)。

前置檢查會在系統將資料庫執行個體停止以進行升級前執行，意即前置檢查執行期間不會造成任何停機時間。如果預先檢查找到不相容，Aurora 會在資料庫執行個體停止前自動取消升級。Aurora 也會為不相容產生事件。如需 Amazon Aurora 事件的詳細資訊，請參閱 [使用 Amazon RDS 事件通知](USER_Events.md)。

Aurora 會在日誌檔案 `PrePatchCompatibility.log` 中記錄每個不相容的相關詳細資訊。在多數情況下，日誌項目包含修正不相容的 MySQL 文件連結。如需檢視日誌檔案的詳細資訊，請參閱[檢視並列出資料庫日誌檔案](USER_LogAccess.Procedural.Viewing.md)。

根據前置檢查的特性，這些檢查作業會分析資料庫中的物件。此分析會耗用資源，並增加升級完成的時間。

# 透過修改引擎版本升級 Aurora MySQL
<a name="AuroraMySQL.Updates.Patching.ModifyEngineVersion"></a>

升級 Aurora MySQL 資料庫叢集的次要版本會將額外的修正程式和新功能套用至現有叢集。

此類升級適用於原始版本和升級版本皆有相同 Aurora MySQL 主要版本 2 或 3 的 Aurora MySQL 叢集。此程序既快速又直接，因為它不涉及 Aurora MySQL 中繼資料的任何轉換或資料表資料的重組。

您可以使用 AWS 管理主控台、AWS CLI 或 RDS API 修改資料庫叢集的引擎版本，以執行此類升級。例如，如果您的叢集正在執行 Aurora MySQL 3.x，請選擇較高的 3.x 版本。

如果要針對 Aurora 全球資料庫執行次要升級，請先升級所有次要叢集，再升級主要叢集。

**注意**  
若要執行次要版本升級至 Aurora MySQL 3.04.\$1 版及更新版本，或 2.12 \$1 版，請遵循下列操作：  
從全域叢集移除所有次要區域。請遵循 [從 Amazon Aurora 全域資料庫中移除叢集](aurora-global-database-detaching.md) 中的步驟。
將主要區域的引擎版本升級至 3.04.\$1 或更新版本，或 2.12.\$1 版 (如適用)。請遵循 [To modify the engine version of a DB cluster](#modify-db-cluster-engine-version) 中的步驟。
將次要區域新增至全域叢集。請遵循 [將 AWS 區域 新增到 Amazon Aurora 全域資料庫](aurora-global-database-attaching.md) 中的步驟。

 **修改資料庫叢集的引擎版本** 
+ **使用主控台** – 修改叢集的屬性。在 **Modify DB cluster (修改資料庫叢集)** 視窗中，變更 **DB engine version (資料庫引擎版本)** 方塊中的 Aurora MySQL 引擎版本。如果您不熟悉修改叢集的一般程序，請遵循 [使用主控台、CLI 和 API 修改資料庫叢集](Aurora.Modifying.md#Aurora.Modifying.Cluster) 中的指示。
+ **透過使用 AWS CLI** – 呼叫 [modify-db-cluster](https://docs.aws.amazon.com/cli/latest/reference/rds/modify-db-cluster.html) AWS CLI 命令，並在 `--db-cluster-identifier` 選項中指定資料庫叢集的名稱，在 `--engine-version` 選項中指定引擎版本。

  例如，若要升級到 Aurora MySQL 3.04.1 版，請將 `--engine-version` 選項設為 `8.0.mysql_aurora.3.04.1`。指定 `--apply-immediately` 選項以立即更新資料庫叢集的引擎版本。
+ **使用 RDS API** – 呼叫 [ModifyDBCluster](https://docs.aws.amazon.com/AmazonRDS/latest/APIReference/API_ModifyDBCluster.html) API 操作，並在 `DBClusterIdentifier` 參數中指定資料庫叢集的名稱，在 `EngineVersion` 參數中指定引擎版本。將 `ApplyImmediately` 參數設為 `true`，以立即更新資料庫叢集的引擎版本。

# 啟用次要 Aurora MySQL 版本之間的自動升級
<a name="AuroraMySQL.Updates.AMVU"></a><a name="amvu"></a>

對於 Amazon Aurora MySQL 資料庫叢集，您可以指定 Aurora 會自動將資料庫叢集升級為新的次要版本。您可以透過設定資料庫叢集的 `AutoMinorVersionUpgrade` 屬性 (AWS 管理主控台 中的**自動次要版本升級**) 來執行此操作。

自動升級會在維護時段期間進行。如果資料庫叢集中的個別資料庫執行個體維護時段不同於叢集維護時段，則會優先考慮叢集維護時段。

自動次要版本升級不適用於下列類型的 Aurora MySQL 叢集：
+ 屬於 Aurora 全域資料庫一部分的叢集
+ 具有跨區域複本的叢集

中斷持續時間視工作負載、叢集大小、二進位記錄資料的數量，以及 Aurora 是否可使用零停機時間修補 (ZDP) 功能而定。Aurora 會重新啟動資料庫叢集，因此在繼續使用叢集之前，您可能會遇到短暫無法使用的狀況。特別是二進位日誌資料的數量會影響復原時間。資料庫執行個體會在復原期間處理二進位記錄資料。因此，大量的二進位記錄資料會增加復原時間。

**注意**  
Aurora 僅在資料庫叢集中的所有資料庫執行個體皆已啟用 `AutoMinorVersionUpgrade` 設定時才會執行自動升級。如需了解如何設定它，以及套用於叢集和執行個體層級時如何運作，請參閱 [Aurora 資料庫叢集的自動次要版本升級](USER_UpgradeDBInstance.Maintenance.md#Aurora.Maintenance.AMVU)。  
然後，如果資料庫叢集執行個體的升級路徑存在，而次要資料庫引擎版本將 `AutoUpgrade` 設為 true，則會進行升級。`AutoUpgrade` 設定是動態的，並由 RDS 設定。  
自動次要版本的升級會執行至預設次要版本。

您可以使用下列 CLI 命令來檢查 Aurora MySQL 叢集中所有資料庫執行個體的`AutoMinorVersionUpgrade`升級設定狀態。

```
aws rds describe-db-instances \
  --query '*[].{DBClusterIdentifier:DBClusterIdentifier,DBInstanceIdentifier:DBInstanceIdentifier,AutoMinorVersionUpgrade:AutoMinorVersionUpgrade}'
```

此命令會產生類似下列的輸出：

```
[
  {
      "DBInstanceIdentifier": "db-t2-medium-instance",
      "DBClusterIdentifier": "cluster-57-2020-06-03-6411",
      "AutoMinorVersionUpgrade": true
  },
  {
      "DBInstanceIdentifier": "db-t2-small-original-size",
      "DBClusterIdentifier": "cluster-57-2020-06-03-6411",
      "AutoMinorVersionUpgrade": false
  },
  {
      "DBInstanceIdentifier": "instance-2020-05-01-2332",
      "DBClusterIdentifier": "cluster-57-2020-05-01-4615",
      "AutoMinorVersionUpgrade": true
  },
... output omitted ...
```

在此範例中，資料庫叢集 `cluster-57-2020-06-03-6411` 的**啟用自動次要版本升級**已關閉，因為叢集的其中一個資料庫執行個體已關閉此功能。

# 使用零停機時間修補
<a name="AuroraMySQL.Updates.ZDP"></a><a name="zdp"></a>

執行資料 Aurora MySQL 資料庫叢集的升級牽涉到資料庫關閉和升級時發生中斷的可能性。根據預設，如果您在資料庫忙碌時開始升級，則會遺失資料庫叢集正在處理的所有連線和交易。如果您要等到資料庫閒置才執行升級，就可能必須等待很長時間。

零停機時間修補 (ZDP) 功能以最佳作法為基礎，試圖在整個 Aurora MySQL 升級過程維持用戶端正常連線。如果 ZDP 成功完成，即可保留應用程式工作階段，資料庫引擎也會在升級期間重新啟動。資料庫引擎重新啟動可能會導致輸送量下降，持續時間為數秒到一分鐘左右。

ZDP 不適用於下列項目：
+ 作業系統 (OS) 修補程式與升級
+ 主要版本升級

ZDP 適用於所有支援的 Aurora MySQL 版本和資料庫執行個體類別。

Aurora Serverless v1 或 Aurora 全球資料庫不支援 ZDP。

**注意**  
建議您在開發、測試伺服器或其他非生產伺服器時，僅使用 T 資料庫執行個體類別。如需詳細了解 T 執行個體類別，請參閱 [使用 T 執行個體類別進行開發和測試](AuroraMySQL.BestPractices.Performance.md#AuroraMySQL.BestPractices.T2Medium)。

您可以在 MySQL 錯誤日誌中查看 ZDP 期間重要屬性的指標。您也可以在 AWS 管理主控台 中的 **Events** (事件) 頁面上，查看 Aurora MySQL 何時使用 ZDP 或選擇不使用 ZDP 的相關資訊。

在 Aurora MySQL 中，不論是否啟用二進位日誌複寫功能，Aurora 皆可執行零停機時間修補。若啟用二進位日誌複寫功能，Aurora MySQL 會在 ZDP 操作期間自動中斷與 binlog 目標的連線。Aurora MySQL 會在重新啟動完成後，自動重新連線到 binlog 目標並繼續複寫。

ZDP 也可與 Aurora MySQL 中的重新開機增強功能搭配使用。修補寫入器資料庫執行個體會同時自動修補讀取器。執行修補程式之後，Aurora 會恢復寫入器和讀取器資料庫執行個體上的連線。

若有以下情況，ZDP 便可能無法成功完成：
+ 長時間執行的查詢或交易正在進行中 如果 Aurora 可以在此情況下執行 ZDP，則會取消任何開啟的交易，但其連線會保留。
+ 暫存資料表、使用者鎖定或資料表鎖定正在使用中，例如資料定義語言 (DDL) 陳述式執行時。Aurora 會捨棄這些連線。
+ 存在擱置中的參數變更。

若因為一或多個上述條件而無執行 ZDP 的合適時段，修補作業會還原至標準行為。

雖然在成功的 ZDP 操作之後連線仍保持不變，但某些變數和功能會重新初始化。下列類型的資訊在零停機修補所造成的重新啟動時不會保留：
+ 全域變數。Aurora 會恢復工作階段變數，但它不會在重新啟動後恢復全域變數。
+ 狀態變數。特別是，引擎狀態報告的正常執行時間值會在使用 ZDR 或 ZDP 機制的重新啟動之後重設。
+ `LAST_INSERT_ID`.
+ 資料表的記憶體內 `auto_increment` 狀態。記憶體內的自動增量狀態會重新初始化。如需自動增量值的詳細資訊，請參閱 [MySQL 參考手冊](https://dev.mysql.com/doc/refman/5.7/en/innodb-auto-increment-handling.html#innodb-auto-increment-initialization)。
+ 來自 `INFORMATION_SCHEMA` 和 `PERFORMANCE_SCHEMA` 資料表的診斷資訊。這項診斷資訊也會出現在 `SHOW PROFILE` 和 `SHOW PROFILES` 等命令的輸出中。

**Events (事件)** 頁面會報告下列與零停機時間重新啟動相關的活動：
+ 嘗試在零停機時間的情況下升級資料庫。
+ 嘗試在零停機時間的情況下升級資料庫已完成。事件會報告程序所花費的時間。此事件也會報告重新啟動期間保留的連線數目，以及已中斷的連線數目。您可以查閱資料庫錯誤日誌，瞭解重新啟動期間所發生情況的相關詳細資訊。

## 替代藍/綠升級技術
<a name="AuroraMySQL.UpgradingMinor.BlueGreen"></a>

在某些情況下，您的首要目標是立即從舊叢集切換至升級的叢集。在這類情況下，您也可以使用多步驟程序，並排執行新舊叢集。在這裡，您會將舊叢集的資料複寫到新叢集，直至您準備好接管新叢集。如需詳細資訊，請參閱 [使用 Amazon Aurora 藍/綠部署進行資料庫更新](blue-green-deployments.md)。

# 升級 Amazon Aurora MySQL 資料庫叢集的主要版本
<a name="AuroraMySQL.Updates.MajorVersionUpgrade"></a><a name="mvu"></a>

在 Aurora MySQL 版本編號 (例如 3.04.1) 中，3 表示主要版本。Aurora MySQL 第 2 版與 MySQL 5.7 相容。Aurora MySQL 第 3 版與 MySQL 8.0 相容。

在主要版本之間進行升級，需要比次要版本更廣泛的規劃和測試。該程序可能需要大量時間。升級完成後，您還可能需要進行後續工作。例如，發生這種情況可能是由於 SQL 相容性的差異或某些 MySQL 相關功能的運作方式所致。或者，可能是因為舊版本和新版本之間的參數設定不同而發生。

**Contents**
+ [從 Aurora MySQL 第 2 版升級到第 3 版](#AuroraMySQL.Updates.MajorVersionUpgrade.2to3)
+ [Aurora MySQL 主要版本升級路徑](#AuroraMySQL.Upgrading.Compatibility)
+ [Aurora MySQL 主要版本就地升級的運作方式](#AuroraMySQL.Upgrading.Sequence)
+ [規劃 Aurora MySQL 叢集的主要版本升級](#AuroraMySQL.Upgrading.Planning)
  + [透過複製資料庫叢集來模擬升級](#AuroraMySQL.Upgrading.Planning.clone)
  + [藍/綠部署](#AuroraMySQL.UpgradingMajor.BlueGreen)
+ [Aurora MySQL 的主要版本升級預先檢查](AuroraMySQL.upgrade-prechecks.md)
  + [Aurora MySQL 的預先檢查程序](AuroraMySQL.upgrade-prechecks.md#AuroraMySQL.upgrade-prechecks.process)
  + [Aurora MySQL 的預先檢查日誌格式](AuroraMySQL.upgrade-prechecks.md#AuroraMySQL.upgrade-prechecks.log-format)
  + [Aurora MySQL 的預先檢查日誌輸出範例](AuroraMySQL.upgrade-prechecks.md#AuroraMySQL.upgrade-prechecks.log-examples)
  + [Aurora MySQL 的預先檢查效能](AuroraMySQL.upgrade-prechecks.md#AuroraMySQL.upgrade-prechecks.performance)
  + [Community MySQL 升級預先檢查摘要](AuroraMySQL.upgrade-prechecks.md#AuroraMySQL.upgrade-prechecks.community)
  + [Aurora MySQL 升級預先檢查摘要](AuroraMySQL.upgrade-prechecks.md#AuroraMySQL.upgrade-prechecks.ams)
  + [Aurora MySQL 的預先檢查描述參考](AuroraMySQL.upgrade-prechecks.descriptions.md)
    + [錯誤](AuroraMySQL.upgrade-prechecks.descriptions.md#precheck-descriptions-errors)
      + [報告錯誤的 MySQL 預先檢查](AuroraMySQL.upgrade-prechecks.descriptions.md#precheck-descriptions-errors.mysql)
      + [Aurora MySQL 會預先檢查報告錯誤](AuroraMySQL.upgrade-prechecks.descriptions.md#precheck-descriptions-errors.aurora)
    + [警告](AuroraMySQL.upgrade-prechecks.descriptions.md#precheck-descriptions-warnings)
      + [報告警告的 MySQL 預先檢查](AuroraMySQL.upgrade-prechecks.descriptions.md#precheck-descriptions-warnings.mysql)
      + [報告警告的 Aurora MySQL 預先檢查](AuroraMySQL.upgrade-prechecks.descriptions.md#precheck-descriptions-warnings.aurora)
    + [注意](AuroraMySQL.upgrade-prechecks.descriptions.md#precheck-descriptions-notices)
    + [錯誤、警告或通知](AuroraMySQL.upgrade-prechecks.descriptions.md#precheck-descriptions-all)
+ [就地升級執行方式](AuroraMySQL.Upgrading.Procedure.md)
  + [就地升級如何影響叢集的參數群組](AuroraMySQL.Upgrading.Procedure.md#AuroraMySQL.Upgrading.ParamGroups)
  + [在 Aurora MySQL 版本之間對叢集屬性的變更](AuroraMySQL.Upgrading.Procedure.md#AuroraMySQL.Upgrading.Attrs)
  + [全域資料庫的就地主要升級](AuroraMySQL.Upgrading.Procedure.md#AuroraMySQL.Upgrading.GlobalDB)
  + [使用跨區域僅供讀取複本進行資料庫叢集就地升級](AuroraMySQL.Upgrading.Procedure.md#AuroraMySQL.Upgrading.XRRR)
+ [Aurora MySQL 會就地升級教學](AuroraMySQL.Upgrading.Tutorial.md)
+ [尋找 Aurora MySQL 主要版本升級失敗的原因](AuroraMySQL.Upgrading.failure-events.md)
+ [Aurora MySQL 就地升級疑難排解](AuroraMySQL.Upgrading.Troubleshooting.md)
+ [Aurora MySQL 第 3 版的升級後清除](AuroraMySQL.mysql80-post-upgrade.md)
  + [空間索引](AuroraMySQL.mysql80-post-upgrade.md#AuroraMySQL.mysql80-spatial)

## 從 Aurora MySQL 第 2 版升級到第 3 版
<a name="AuroraMySQL.Updates.MajorVersionUpgrade.2to3"></a>

如果您有與 MySQL 576 相容的叢集，並且希望將其升級至與 MySQL 8.0 相容的叢集，可以在叢集本身執行升級程序來實現此操作。這種升級為*就地升級*，與之形成對照的是，建立新叢集時所做的升級。這項技術會保留相同的端點和叢集的其他特性。升級速度相對較快，因為不需要將所有資料複製到新的叢集磁碟區。此穩定性有助於將應用程式中的任何組態變更降至最低。此外，還有助於減少已升級叢集的測試量。這是因為資料庫執行個體及其執行個體類別的數目都保持不變。

就地升級機制在操作時涉及關閉您的資料庫叢集。Aurora 會執行正常關閉並完成未完成的操作，例如交易回復和還原清除。如需詳細資訊，請參閱[Aurora MySQL 主要版本就地升級的運作方式](#AuroraMySQL.Upgrading.Sequence)。

就地升級方法非常便捷，因為執行相關應用程式的組態變更非常簡單，並且可將組態變更降至最低。例如，就地升級會保留叢集的端點和資料庫執行個體集。不過，就地升級所需的時間可能會因結構描述的屬性，以及叢集的忙碌程度而有所差異。因此，根據叢集的需求，您可以在各種升級技術之間進行選擇。
+ [就地升級](AuroraMySQL.Upgrading.Procedure.md)
+ [藍/綠部署](#AuroraMySQL.UpgradingMajor.BlueGreen)
+ [快照還原](aurora-restore-snapshot.md)
**注意**  
如果您使用 AWS CLI 或 RDS API 進行快照還原升級方法，則必須執行後續操作，以在還原的資料庫叢集中建立寫入器資料庫執行個體。

如需 Aurora MySQL 第 3 版及其新功能的一般資訊，請參閱 [Aurora MySQL 第 3 版與 MySQL 8.0 相容](AuroraMySQL.MySQL80.md)。

如需有關規劃升級的詳細資訊，請參閱 [規劃 Aurora MySQL 叢集的主要版本升級](#AuroraMySQL.Upgrading.Planning) 和 [就地升級執行方式](AuroraMySQL.Upgrading.Procedure.md)。

## Aurora MySQL 主要版本升級路徑
<a name="AuroraMySQL.Upgrading.Compatibility"></a>

並非所有種類或版本的 Aurora MySQL 叢集都可以使用就地升級機制。您可以參閱下表，了解每個 Aurora MySQL 叢集的適當升級路徑。


|  Aurora MySQL 資料庫叢集的類型  | 是否可以採用就地升級？  |  Action  | 
| --- | --- | --- | 
|   Aurora MySQL 佈建叢集，第 2 版  |  是  |  與 5.7 相容的 Aurora MySQL 叢集支援就地升級。 如需升級至 Aurora MySQL 第 3 版的相關資訊，請參閱 [規劃 Aurora MySQL 叢集的主要版本升級](#AuroraMySQL.Upgrading.Planning)和[就地升級執行方式](AuroraMySQL.Upgrading.Procedure.md)。  | 
|   Aurora MySQL 佈建叢集，第 3 版  |  不適用  |  使用次要版本升級程序，在 Aurora MySQL 第 3 版之間進行升級。  | 
|  Aurora Serverless v1 叢集  |  不適用  |  僅在第 2 版上，Aurora MySQL 才會支援 Aurora Serverless v1。  | 
|  Aurora Serverless v2 叢集  |  不適用  | 僅在第 3 版上，Aurora MySQL 才會支援 Aurora Serverless v2。 | 
|  Aurora 全域資料庫中的叢集  |  是  |  若要將 Aurora MySQL 第 2 版升級至第 3 版，請遵循 Aurora 全域資料庫中叢集的[進行就地升級的程序](AuroraMySQL.Upgrading.Procedure.md)。在全域叢集上執行升級。Aurora 會同時升級全域資料庫中的主要叢集和所有次要叢集。 如果您使用 AWS CLI 或 RDS API，請呼叫 `modify-global-cluster`命令或 `ModifyGlobalCluster` 操作，而不是 `modify-db-cluster`或 `ModifyDBCluster`。 只有在 `lower_case_table_names` 參數設為預設值且重新啟動全球資料庫時，您才能從 Aurora MySQL 第 2 版就地升級至第 3 版。如需詳細資訊，請參閱[主要版本升級](aurora-global-database-upgrade.md#aurora-global-database-upgrade.major)。  | 
|  平行查詢叢集  |  是  |  您可以執行就地升級。  | 
|  二進位日誌複寫目標的叢集  |  也許可以  |  如果二進位日誌複寫來自 Aurora MySQL 叢集，您可以執行就地升級。如果二進位日誌複寫來自 RDS MySQL 或內部部署 MySQL 資料庫執行個體，則無法執行升級。在這種情況下，您可以使用快照還原機制進行升級。  | 
|  具有零資料庫執行個體的叢集  |  否  |  您可以使用 AWS CLI 或 RDS API，在沒有連接任何資料庫執行個體的情況下建立 Aurora MySQL 叢集。同樣，您也可以從 Aurora MySQL 叢集移除所有資料庫執行個體，同時保持叢集磁碟區中的資料完好。雖然叢集具有零資料庫執行個體，但您無法執行就地升級。 升級機制需要叢集中的寫入器執行個體，才能對系統資料表、資料檔案等執行轉換。在此情況下，請使用 AWS CLI 或 RDS API 為叢集建立寫入器執行個體。然後可以執行就地升級。  | 
|  啟用恢復的叢集  |  是  |  您可以針對使用恢復功能的 Aurora MySQL 叢集，執行就地升級。不過升級之後，您無法將叢集恢復到升級前的時間。  | 

## Aurora MySQL 主要版本就地升級的運作方式
<a name="AuroraMySQL.Upgrading.Sequence"></a>

 Aurora MySQL 會將主要版本升級作為多階段程序執行。您可以檢查升級的目前狀態。某些升級步驟也會提供進度資訊。每個階段開始時，Aurora MySQL 會記錄事件。您可以在事件發生時，在 RDS 主控台的 **Events** (事件) 頁面上檢查事件。如需使用事件的資訊，請參閱[使用 Amazon RDS 事件通知](USER_Events.md)。

**重要**  
 程序開始後即會執行，直至升級成功或失敗為止。升級進行中時，無法取消升級。如果升級失敗，Aurora 會復原所有變更，且您的叢集具有相同的引擎版本、中繼資料等，與之前一樣。

 升級程序包含三個階段：

1.  Aurora 會在開始升級程序之前執行一系列[預先檢查](AuroraMySQL.upgrade-prechecks.md)。Aurora 在執行這些檢查時，叢集會持續執行。例如，叢集不能有任何 XA 交易處於準備狀態，或者正在處理任何資料定義語言 (DDL) 陳述式。例如，您可能需要關閉提交特定類型的 SQL 陳述式的應用程式。或者，您可以直接等到某些長時間執行的陳述式完成。然後再次嘗試升級。某些檢查會測試無法阻止升級，但可能會使升級需要很長時間的條件。

    如果 Aurora 偵測到不符合任何必要條件，請修改事件詳細資訊中識別的條件。請遵循 [Aurora MySQL 就地升級疑難排解](AuroraMySQL.Upgrading.Troubleshooting.md) 中的指引。如果 Aurora 偵測到可能導致升級緩慢的條件，請規劃長期監控升級。

1.  Aurora 會使叢集離線。然後 Aurora 會執行類似的一組測試，如上一階段，以確認關閉程序中沒有出現任何新問題。如果此時 Aurora 偵測到任何可能阻止升級的條件，Aurora 會取消升級並使叢集恢復線上狀態。在這種情況下，請確認條件何時不再適用，然後再次開始升級。

1.  Aurora 會建立叢集磁碟區的快照。假設您在升級完成後，發現相容性或其他類型的問題。或者，假設您想要同時使用原始叢集和升級的叢集來執行測試。在這種情況下，您可以從此快照還原，以建立具有原始引擎版本和原始資料的新叢集。
**提示**  
此快照為手動快照。不過，即使您已達到手動快照的配額，Aurora 也可以建立快照並繼續進行升級程序。此快照會永久保留 (如有需要)，直至您將其刪除。完成所有升級後測試之後，您可以刪除此快照，將儲存費用降至最低。

1.  Aurora 會複製您的叢集磁碟區。複製是一個快速操作，不涉及複製實際的資料表資料。如果在升級期間 Aurora 遇到問題，它會從複製的叢集磁碟區還原為原始資料，並使叢集恢復線上狀態。升級期間暫時複製的磁碟區不受單一叢集磁碟區複製數目的一般限制。

1.  Aurora 會執行寫入器資料庫執行個體的正常關閉。在正常關閉期間，進行下列操作的進度事件每 15 分鐘記錄一次。您可以在事件發生時，在 RDS 主控台的 **Events** (事件) 頁面上檢查事件。
   +  Aurora 會清除舊版本資料列的還原記錄。
   +  Aurora 會復原任何未遞交的交易。

1.  Aurora 會升級寫入器資料庫執行個體上的引擎版本：
   +  Aurora 會在寫入器資料庫執行個體上安裝新引擎版本的二進位檔。
   +  Aurora 會使用寫入器資料庫執行個體，將您的資料升級為 MySQL 5.7 相容的格式。在此階段，Aurora 會修改系統資料表，並執行其他會影響叢集磁碟區中資料的轉換。特別是，Aurora 會將系統資料表中的分割區中繼資料，升級為與 MySQL 5.7 分割區格式相容。如果叢集中的資料表具有大量的分割區，此階段可能需要很長時間。

      如果在此階段發生任何錯誤，您可以在 MySQL 錯誤日誌中找到詳細資訊。在此階段開始之後，如果升級程序因任何原因失敗，Aurora 會從複製的叢集磁碟區還原該原始資料。

1.  Aurora 會升級讀取器資料庫執行個體上的引擎版本。

1.  升級程序已完成。Aurora 會記錄最終事件，以指示升級程序已順利完成。現在，您的資料庫叢集正在執行新的主要版本。

## 規劃 Aurora MySQL 叢集的主要版本升級
<a name="AuroraMySQL.Upgrading.Planning"></a>

為了協助您決定正確的升級時間和方法，您可以了解 Aurora MySQL 第 3 版與目前 Aurora 和 MySQL 環境之間的差異：
+ 如果您是從 RDS for MySQL 8.0 或 MySQL 8.0 社群版轉換，請參閱 [比較 Aurora MySQL 第 3 版與 MySQL 8.0 社群版](AuroraMySQL.Compare-80-v3.md)。
+ 如果您是從 Aurora MySQL 第 2 版、RDS for MySQL 5.7 或社群 MySQL 5.7 升級，請參閱 [比較 Aurora MySQL 第 2 版和 Aurora MySQL 第 3 版](AuroraMySQL.Compare-v2-v3.md)。
+ 為任何自訂參數群組建立新的 MySQL 8.0 相容版本。將任何必要的自訂參數值套用至新的參數群組。請參閱 [Aurora MySQL 第 3 版的參數變更](AuroraMySQL.Compare-v2-v3.md#AuroraMySQL.mysql80-parameter-changes)以了解參數變更。
+ 在升級之前，請檢閱您的 Aurora MySQL 第 2 版資料庫結構描述和物件定義，取得 MySQL 8.0 Community Edition 中引入的新保留關鍵字的使用方式。在升級之前執行此操作。如需詳細資訊，請參閱 MySQL 文件中的 [MySQL 8.0 New Keywords and Reserved Words](https://dev.mysql.com/doc/mysqld-version-reference/en/keywords-8-0.html#keywords-new-in-8-0) (MySQL 8.0 新關鍵字與保留字)。

您也可以在《MySQL 參考手冊》**中的 [MySQL 8.0 中的變更](https://dev.mysql.com/doc/refman/8.0/en/upgrading-from-previous-series.html)，尋找其他 MySQL 特定升級考量和秘訣。例如，您可以使用命令 `mysqlcheck --check-upgrade` 來分析您現有的 Aurora MySQL 資料庫，並找出潛在的升級問題。

**注意**  
使用就地升級或快照還原技術升級至 Aurora MySQL 第 3 版時，建議使用較大的資料庫執行個體類別。範例為 db.r5.24xlarge 和 db.r6g.16xlarge。這有助於使用資料庫執行個體上的大多數可用 CPU 容量，加快升級程序的完成速度。您可以在主要版本升級完成後變更為所需的資料庫執行個體類別。

完成升級本身後，您可以按照 [Aurora MySQL 第 3 版的升級後清除](AuroraMySQL.mysql80-post-upgrade.md) 中的升級後程序來操作。最後，測試應用程式的功能和效能。

如果您是從 RDS for MySQL 或社群 MySQL 轉換，請遵循[將資料遷移至 Amazon Aurora MySQL 資料庫叢集](AuroraMySQL.Migrating.md)中說明的遷移程序。在某些情況下，您可能會使用二進位日誌複寫，將資料與 Aurora MySQL 第 3 版叢集同步，做為遷移的一部分。若是如此，來源系統必須執行與您的目標資料庫叢集相容的版本。

若要確保在主要版本之間升級叢集之後，您的應用程式和管理程序可以順利運作，請進行一些預先規劃和準備。若要查看要更新 AWS CLI 指令碼或 RDS API 型應用程式的管理程式碼，請參閱 [就地升級如何影響叢集的參數群組](AuroraMySQL.Upgrading.Procedure.md#AuroraMySQL.Upgrading.ParamGroups)。另請參閱[在 Aurora MySQL 版本之間對叢集屬性的變更](AuroraMySQL.Upgrading.Procedure.md#AuroraMySQL.Upgrading.Attrs)。

若要了解升級期間可能會遇到的問題，請參閱 [Aurora MySQL 就地升級疑難排解](AuroraMySQL.Upgrading.Troubleshooting.md)。對於可能導致升級需要很長時間的問題，您可以預先測試這些條件並進行更正。

**注意**  
就地升級在操作時涉及關閉您的資料庫叢集。Aurora MySQL 會執行正常關閉並完成未完成的操作，例如還原清除。如果有許多復原記錄需要清除，則升級可能需要很長的時間。我們建議只在歷史記錄清單長度 (HLL) 很低之後才執行升級。HLL 的一般可接受值為 100,000 或更少。如需詳細資訊，請參閱這篇[部落格文章](https://aws.amazon.com/blogs/database/amazon-aurora-mysql-version-2-with-mysql-5-7-compatibility-to-version-3-with-mysql-8-0-compatibility-upgrade-checklist-part-2)。

### 透過複製資料庫叢集來模擬升級
<a name="AuroraMySQL.Upgrading.Planning.clone"></a>

您可以針對升級的叢集檢查應用程式相容性、效能、維護程序和類似考量。若要這樣做，您可以在進行真正的升級之前執行升級的模擬。此技術對於生產叢集特別有用。在此，務必將停機時間降至最低，並在升級完成後立即準備好升級的叢集。

使用下列步驟：

1. 建立原始叢集的複製。請遵循 [複製 Amazon Aurora 資料庫叢集的一個磁碟區](Aurora.Managing.Clone.md) 中的程序。

1. 設定與原始叢集相似的一組寫入器和讀取器資料庫執行個體。

1. 執行複製叢集的就地升級。請遵循 [就地升級執行方式](AuroraMySQL.Upgrading.Procedure.md) 中的程序。

   建立複製後立即開始升級。如此一來，叢集磁碟區仍與原始叢集的狀態相同。如果複製在進行升級之前閒置，Aurora 會在後台執行資料庫清除程序。在這種情況下，複製的升級並非正確的升級原始叢集模擬。

1. 使用複製的叢集測試應用程式相容性、效能、管理程序等。

1. 如果您遇到任何問題，請調整升級計劃以解決這些問題。例如，調整任何應用程式的程式碼，以便與更高版本的功能集相容。根據叢集中的資料量，估計升級可能需要多長時間。您還可以選擇在叢集不忙碌的時間排程升級。

1. 在您對應用程式和工作負載適當地使用測試叢集感到滿意之後，即可執行生產叢集的就地升級。

1. 在主要版本升級期間，努力將叢集的總停機時間降到最低。若要這樣做，請確定叢集上的工作負載在升級時很低或為零。特別是，請確定在您啟動升級時，沒有長時間執行的交易正在進行。

### 藍/綠部署
<a name="AuroraMySQL.UpgradingMajor.BlueGreen"></a>

在某些情況下，您的首要目標是立即從舊叢集切換至升級的叢集。在這類情況下，您也可以使用多步驟程序，並排執行新舊叢集。在這裡，您會將舊叢集的資料複寫到新叢集，直至您準備好接管新叢集。如需詳細資訊，請參閱 [使用 Amazon Aurora 藍/綠部署進行資料庫更新](blue-green-deployments.md)。

# Aurora MySQL 的主要版本升級預先檢查
<a name="AuroraMySQL.upgrade-prechecks"></a>

從一個主要版本升級 MySQL 到另一個主要版本，例如從 MySQL 5.7 到 MySQL 8.0，涉及一些需要仔細規劃和準備的重大架構變更。與主要著重於更新資料庫引擎軟體的次要版本升級，以及在某些情況下的系統資料表不同，主要 MySQL 升級通常會對資料庫存放和管理其中繼資料的方式帶來重大變更。

為了協助您識別這種不相容，從 Aurora MySQL 第 2 版升級至第 3 版時，Aurora 會自動執行升級相容性檢查 (預先檢查)，以檢查資料庫叢集中的物件，並識別已知可能會防止升級繼續進行的不相容。如需 Aurora MySQL 預先檢查的詳細資訊，請參閱 [Aurora MySQL 的預先檢查描述參考](AuroraMySQL.upgrade-prechecks.descriptions.md)。Aurora 預先檢查會在 Community MySQL [升級檢查程式公用程式](https://dev.mysql.com/doc/mysql-shell/8.0/en/mysql-shell-utilities-upgrade.html)執行的檢查以外執行。

系統會強制執行這些前置檢查，您無法選擇略過這些檢查。前置檢查提供以下優勢：
+ 它們可以降低發生升級失敗的可能性，這可能會導致延長停機時間。
+ 出現不相容情況時，Amazon Aurora 即會防止系統繼續升級，並提供相關日誌讓您了解。如此，您就可以使用這些日誌來減少不相容情況，為資料庫做好升級至第 3 版 的準備。如需解決不相容問題的詳細資訊，請參閱 MySQL 文件中的[準備您的安裝進行升級](https://dev.mysql.com/doc/refman/8.0/en/upgrade-prerequisites.html)，以及 MySQL 部落格上的[升級至 MySQL 8.0？ 這裡是您需要知道的事項...](https://dev.mysql.com/blog-archive/upgrading-to-mysql-8-0-here-is-what-you-need-to-know/)。

  如需升級至 MySQL 8.0 的詳細資訊，請參閱 MySQL 文件中的 [Upgrading MySQL](https://dev.mysql.com/doc/refman/8.0/en/upgrading.html) (升級 MySQL)。

預先檢查會在資料庫叢集離線以進行主要版本升級之前執行。如果預先檢查找到不相容，Aurora 會在資料庫執行個體停止前自動取消升級。Aurora 也會為不相容產生事件。如需 Amazon Aurora 事件的詳細資訊，請參閱 [使用 Amazon RDS 事件通知](USER_Events.md)。

完成預先檢查後，Aurora 會記錄 `upgrade-prechecks.log` 檔案中每個不相容的詳細資訊。在多數情況下，日誌項目包含修正不相容的 MySQL 文件連結。如需檢視日誌檔案的詳細資訊，請參閱[檢視並列出資料庫日誌檔案](USER_LogAccess.Procedural.Viewing.md)。

**注意**  
根據前置檢查的特性，這些檢查作業會分析資料庫中的物件。此分析會耗用資源，並增加升級完成的時間。如需預先檢查效能考量的詳細資訊，請參閱 [Aurora MySQL 的預先檢查程序](#AuroraMySQL.upgrade-prechecks.process)。

**Contents**
+ [Aurora MySQL 的預先檢查程序](#AuroraMySQL.upgrade-prechecks.process)
+ [Aurora MySQL 的預先檢查日誌格式](#AuroraMySQL.upgrade-prechecks.log-format)
+ [Aurora MySQL 的預先檢查日誌輸出範例](#AuroraMySQL.upgrade-prechecks.log-examples)
+ [Aurora MySQL 的預先檢查效能](#AuroraMySQL.upgrade-prechecks.performance)
+ [Community MySQL 升級預先檢查摘要](#AuroraMySQL.upgrade-prechecks.community)
+ [Aurora MySQL 升級預先檢查摘要](#AuroraMySQL.upgrade-prechecks.ams)
+ [Aurora MySQL 的預先檢查描述參考](AuroraMySQL.upgrade-prechecks.descriptions.md)
  + [錯誤](AuroraMySQL.upgrade-prechecks.descriptions.md#precheck-descriptions-errors)
    + [報告錯誤的 MySQL 預先檢查](AuroraMySQL.upgrade-prechecks.descriptions.md#precheck-descriptions-errors.mysql)
    + [Aurora MySQL 會預先檢查報告錯誤](AuroraMySQL.upgrade-prechecks.descriptions.md#precheck-descriptions-errors.aurora)
  + [警告](AuroraMySQL.upgrade-prechecks.descriptions.md#precheck-descriptions-warnings)
    + [報告警告的 MySQL 預先檢查](AuroraMySQL.upgrade-prechecks.descriptions.md#precheck-descriptions-warnings.mysql)
    + [報告警告的 Aurora MySQL 預先檢查](AuroraMySQL.upgrade-prechecks.descriptions.md#precheck-descriptions-warnings.aurora)
  + [注意](AuroraMySQL.upgrade-prechecks.descriptions.md#precheck-descriptions-notices)
  + [錯誤、警告或通知](AuroraMySQL.upgrade-prechecks.descriptions.md#precheck-descriptions-all)

## Aurora MySQL 的預先檢查程序
<a name="AuroraMySQL.upgrade-prechecks.process"></a>

如前所述，Aurora MySQL 升級程序涉及在資料庫上執行相容性檢查 (預先檢查)，然後才能繼續主要版本升級。

對於就地升級，預先檢查會在寫入器資料庫執行個體上線時對其執行。如果預先檢查成功，升級會繼續進行。如果發現錯誤，則會記錄在 `upgrade-prechecks.log` 檔案中，並取消升級。再次嘗試升級之前，請先解決 `upgrade-prechecks.log` 檔案中傳回的任何錯誤。

對於快照還原升級，預先檢查會在還原程序期間執行。如果成功，您的資料庫將升級至新的 Aurora MySQL 版本。如果發現錯誤，則會記錄在 `upgrade-prechecks.log` 檔案中，並取消升級。再次嘗試升級之前，請先解決 `upgrade-prechecks.log` 檔案中傳回的任何錯誤。

如需詳細資訊，請參閱[尋找 Aurora MySQL 主要版本升級失敗的原因](AuroraMySQL.Upgrading.failure-events.md)及[Aurora MySQL 的預先檢查描述參考](AuroraMySQL.upgrade-prechecks.descriptions.md)。

若要監控預先檢查狀態，您可以在資料庫叢集上檢視下列事件。


| 預先檢查狀態 | 事件訊息 | Action | 
| --- | --- | --- | 
|  已開始  |  升級準備進行中：開始線上升級預先檢查。  | 無 | 
|  失敗  |  資料庫叢集處於無法升級的狀態：升級預先檢查失敗。如需詳細資訊，請參閱 upgrade-prechecks.log 檔案。 如需故障診斷升級失敗原因的詳細資訊，請參閱 [https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/AuroraMySQL.Upgrading.Troubleshooting.html](https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/AuroraMySQL.Upgrading.Troubleshooting.html)  |  檢閱錯誤的 `upgrade-prechecks.log`。 修正錯誤。 重試升級。  | 
|  Succeeded  |  升級準備進行中：已完成線上升級預先檢查。  |  預先檢查成功，未傳回錯誤。 檢閱警告和通知的 `upgrade-prechecks.log`。  | 

如需檢視事件的詳細資訊，請參閱 [檢視 Amazon RDS 事件](USER_ListEvents.md)。

## Aurora MySQL 的預先檢查日誌格式
<a name="AuroraMySQL.upgrade-prechecks.log-format"></a>

升級相容性檢查 (預先檢查) 完成後，您可以檢閱 `upgrade-prechecks.log` 檔案。日誌檔案包含每個預先檢查的結果、受影響的物件和修正資訊。

錯誤會封鎖升級。您必須先解決這些錯誤，才能重試升級。

警告和通知較不重要，但仍建議您仔細檢閱，以確保應用程式工作負載沒有相容性問題。盡快解決任何已識別的問題。

日誌檔案的格式如下：
+ `targetVersion` – Aurora MySQL 升級的 MySQL 相容版本。
+ `auroraServerVersion` – 執行預先檢查的 Aurora MySQL 版本。
+ `auroraTargetVersion` – 您要升級的 Aurora MySQL 版本。
+ `checksPerformed` – 包含已執行的預先檢查清單。
+ `id` – 正在執行的預先檢查名稱。
+ `title` – 正在執行的預先檢查描述。
+ `status` – 這不表示預先檢查成功或失敗，但會顯示預先檢查查詢的狀態：
  + `OK` – 預先檢查查詢已成功執行並完成。
  + `ERROR` – 預先檢查查詢無法執行。這可能是因為資源限制、意外執行個體重新啟動或相容性預先檢查查詢中斷等問題而發生。

    如需詳細資訊，請參閱[此範例](#precheck-query-failed)。
+ `description` – 不相容的一般描述，以及如何修正問題。
+ `documentationLink` – 如適用，此處會記下相關 Aurora MySQL 或 MySQL 文件的連結。如需詳細資訊，請參閱[Aurora MySQL 的預先檢查描述參考](AuroraMySQL.upgrade-prechecks.descriptions.md)。
+ `detectedProblems` – 如果預先檢查傳回錯誤、警告或通知，這會顯示不相容的詳細資訊，以及適用的不相容物件：
  + `level` – 預先檢查偵測到的不相容層級。有效層級如下：
    + `Error` – 您必須先解決不相容的問題，才能繼續升級。
    + `Warning` – 升級可以繼續，但偵測到已棄用的物件、語法或組態。請仔細檢閱警告，並盡快解決，以避免未來版本發生問題。
    + `Notice` – 升級可以繼續，但偵測到已棄用的物件、語法或組態。請仔細檢閱通知，並盡快解決，以避免未來版本發生問題。
  + `dbObject` – 偵測到不相容的資料庫物件名稱。
  + `description` – 不相容的詳細描述，以及如何修正問題。
+ `errorCount` – 偵測到的不相容錯誤數目。這些會封鎖升級。
+ `warningCount` – 偵測到的不相容警告數量。這些不會封鎖升級，但請盡快解決，以避免未來版本發生問題。
+ `noticeCount` – 偵測到的不相容通知數量。這些不會封鎖升級，請盡快解決，以避免未來版本發生問題。
+ `Summary` – 預先檢查相容性錯誤、警告和通知計數的摘要。

## Aurora MySQL 的預先檢查日誌輸出範例
<a name="AuroraMySQL.upgrade-prechecks.log-examples"></a>

下列範例顯示您可能會看到的預先檢查日誌輸出。如需執行中預先檢查的詳細資訊，請參閱 [Aurora MySQL 的預先檢查描述參考](AuroraMySQL.upgrade-prechecks.descriptions.md)。

**預先檢查狀態正常，未偵測到不相容**  
預先檢查查詢已成功完成。未偵測到不相容。  

```
{
  "id": "auroraUpgradeCheckIndexLengthLimitOnTinytext",
  "title": "Check for the tables with indexes defined with prefix length greater than 255 bytes on tiny text columns",
  "status": "OK",
  "detectedProblems": []
},
```

**預先檢查狀態正常，偵測到錯誤**  
預先檢查查詢已成功完成。偵測到一個錯誤。  

```
{
  "id": "auroraUpgradeCheckForPrefixIndexOnGeometryColumns",
  "title": "Check for geometry columns on prefix indexes",
  "status": "OK",
  "description": "Consider dropping the prefix indexes of geometry columns and restart the upgrade.",
  "detectedProblems": [
      {
        "level": "Error",
        "dbObject": "test25.sbtest1",
        "description": "Table `test25`.`sbtest1` has an index `idx_t1` on geometry column/s. Mysql 8.0 does not support this type of index on a geometry column https://dev.mysql.com/worklog/task/?id=11808. To upgrade to MySQL 8.0, Run 'DROP INDEX `idx_t1` ON `test25`.`sbtest1`;"
      },
 }
```

**預先檢查狀態正常，偵測到警告**  
當預先檢查成功或失敗時，可能會傳回警告。  
在這裡，預先檢查查詢已成功完成。偵測到兩個警告。  

```
{
  "id": "zeroDatesCheck",
  "title": "Zero Date, Datetime, and Timestamp values",
  "status": "OK",
  "description": "Warning: By default zero date/datetime/timestamp values are no longer allowed in MySQL, as of 5.7.8 NO_ZERO_IN_DATE and NO_ZERO_DATE are included in SQL_MODE by default. These modes should be used with strict mode as they will be merged with strict mode in a future release. If you do not include these modes in your SQL_MODE setting, you are able to insert date/datetime/timestamp values that contain zeros. It is strongly advised to replace zero values with valid ones, as they may not work correctly in the future.",
  "documentationLink": "https://lefred.be/content/mysql-8-0-and-wrong-dates/",
  "detectedProblems": [
      {
        "level": "Warning",
        "dbObject": "global.sql_mode",
        "description": "does not contain either NO_ZERO_DATE or NO_ZERO_IN_DATE which allows insertion of zero dates"
      },
      {
        "level": "Warning",
        "dbObject": "session.sql_mode",
        "description": " of 10 session(s) does not contain either NO_ZERO_DATE or NO_ZERO_IN_DATE which allows insertion of zero dates"
      }
    ]
}
```

**預先檢查狀態錯誤，未回報不相容**  
預先檢查查詢失敗並發生錯誤，因此無法確認不相容。  

```
{
  "id": "auroraUpgradeCheckForDatafilePathInconsistency",
  "title": "Check for inconsistency related to ibd file path.",
  "status": "ERROR",
  "description": "Can't connect to MySQL server on 'localhost:3306' (111) at 13/08/2024 12:22:20 UTC. This failure can occur due to low memory available on the instance for executing upgrade prechecks. Please check 'FreeableMemory' Cloudwatch metric to verify the available memory on the instance while executing prechecks. If instance ran out of memory, we recommend to retry the upgrade on a higher instance class."
}
```
此失敗可能是因為未預期的執行個體重新啟動，或執行時資料庫上的相容性預先檢查查詢中斷。例如，在較小的資料庫執行個體類別上，當執行個體上的可用記憶體不足時，您可能會遇到這種情況。  
您可以使用 `FreeableMemory` Amazon CloudWatch 指標，在執行預先檢查時確認執行個體上的可用記憶體。如果執行個體記憶體不足，建議您在較大的資料庫執行個體類別上重試升級。在某些情況下，您可以使用[藍/綠部署](blue-green-deployments-overview.md) 這可讓預先檢查和升級在與生產工作負載無關的「綠」資料庫叢集上執行，這也會使用系統資源。  
如需詳細資訊，請參閱[針對 Aurora MySQL 資料庫的記憶體用量問題進行故障診斷](ams-workload-memory.md)。

**預先檢查摘要，偵測到一個錯誤和三個警告**  
相容性預先檢查也包含來源和目標 Aurora MySQL 版本的資訊，以及預先檢查輸出結束時的錯誤、警告和通知計數摘要。  
例如，下列輸出顯示嘗試從 Aurora MySQL 2.11.6 升級到 Aurora MySQL 3.07.1。升級傳回一個錯誤、三個警告，而且沒有通知。由於在傳回錯誤時無法繼續升級，您必須解決 [routineSyntaxCheck](AuroraMySQL.upgrade-prechecks.descriptions.md#routineSyntaxCheck) 相容性問題，然後重試升級。  

```
{
  "serverAddress": "/tmp%2Fmysql.sock",
  "serverVersion": "5.7.12 - MySQL Community Server (GPL)",
  "targetVersion": "8.0.36",
  "auroraServerVersion": "2.11.6",
  "auroraTargetVersion": "3.07.1",
  "outfilePath": "/rdsdbdata/tmp/PreChecker.log",
  "checksPerformed": [{
      ... output for each individual precheck ...
      .
      .
      {
        "id": "oldTemporalCheck",
        "title": "Usage of old temporal type",
        "status": "OK",
          "detectedProblems": []
      },
      {
        "id": "routinesSyntaxCheck",
        "title": "MySQL 8.0 syntax check for routine-like objects",
        "status": "OK",
        "description": "The following objects did not pass a syntax check with the latest MySQL 8.0 grammar. A common reason is that they reference names that conflict with new reserved keywords. You must update these routine definitions and `quote` any such references before upgrading.",
        "documentationLink": "https://dev.mysql.com/doc/refman/en/keywords.html",
        "detectedProblems": [{
            "level": "Error",
            "dbObject": "test.select_res_word",
            "description": "at line 2,18: unexpected token 'except'"
        }]
      },
      .
      .
      .
      {
        "id": "zeroDatesCheck",
        "title": "Zero Date, Datetime, and Timestamp values",
        "status": "OK",
        "description": "Warning: By default zero date/datetime/timestamp values are no longer allowed in MySQL, as of 5.7.8 NO_ZERO_IN_DATE and NO_ZERO_DATE are included in SQL_MODE by default. These modes should be used with strict mode as they will be merged with strict mode in a future release. If you do not include these modes in your SQL_MODE setting, you are able to insert date/datetime/timestamp values that contain zeros. It is strongly advised to replace zero values with valid ones, as they may not work correctly in the future.",
        "documentationLink": "https://lefred.be/content/mysql-8-0-and-wrong-dates/",
        "detectedProblems": [{
            "level": "Warning",
            "dbObject": "global.sql_mode",
            "description": "does not contain either NO_ZERO_DATE or NO_ZERO_IN_DATE which allows insertion of zero dates"
            },
            {
            "level": "Warning",
            "dbObject": "session.sql_mode",
            "description": " of 8 session(s) does not contain either NO_ZERO_DATE or NO_ZERO_IN_DATE which allows insertion of zero dates"
            }
          ]
       },
       .
       .
       .
  }],
  "errorCount": 1,
  "warningCount": 3,
  "noticeCount": 0,
  "Summary": "1 errors were found. Please correct these issues before upgrading to avoid compatibility issues."
}
```

## Aurora MySQL 的預先檢查效能
<a name="AuroraMySQL.upgrade-prechecks.performance"></a>

相容性預先檢查會在資料庫執行個體離線以進行升級之前執行，因此在一般情況下，不會在執行時導致資料庫執行個體停機時間。不過，它們可能會影響寫入器資料庫執行個體上執行的應用程式工作負載。預先檢查會透過 [information\$1schema](https://dev.mysql.com/doc/mysql-infoschema-excerpt/5.7/en/information-schema-introduction.html) 資料表存取資料字典，如果有許多資料庫物件，可能會很慢。請考慮下列因素：
+ 預先檢查持續時間會因資料表、資料欄、常式和限制條件等資料庫物件數量而有所不同。具有大量物件的資料庫叢集可能需要更長的時間來執行。

  例如，[removedFunctionsCheck](AuroraMySQL.upgrade-prechecks.descriptions.md#removedFunctionsCheck) 可能需要更長的時間，並根據[儲存的物件](https://dev.mysql.com/doc/refman/5.7/en/stored-objects.html)數量使用更多資源。
+ 對於就地升級，使用較大的資料庫執行個體類別 (例如 db.r5.24xlarge 或 db.r6g.16xlarge) 可以透過使用更多 CPU 協助更快完成升級。您可以在升級後縮減大小。
+ 跨多個資料庫對 `information_schema` 的查詢可能會很慢，尤其是在許多物件和較小的資料庫執行個體上。在這種情況下，請考慮使用複製、快照還原或[藍/綠部署](blue-green-deployments-overview.md)進行升級。
+ 預先檢查資源用量 (CPU、記憶體) 可能會隨著更多物件而增加，導致較小資料庫執行個體上的執行時間更長。在這種情況下，請考慮使用複製、快照還原或藍/綠部署進行測試以進行升級。

  如果預先檢查因資源不足而失敗，您可以使用狀態輸出在預先檢查日誌中偵測到此問題：

  ```
  "status": "ERROR",
  ```

如需詳細資訊，請參閱[Aurora MySQL 主要版本就地升級的運作方式](AuroraMySQL.Updates.MajorVersionUpgrade.md#AuroraMySQL.Upgrading.Sequence)及[規劃 Aurora MySQL 叢集的主要版本升級](AuroraMySQL.Updates.MajorVersionUpgrade.md#AuroraMySQL.Upgrading.Planning)。

## Community MySQL 升級預先檢查摘要
<a name="AuroraMySQL.upgrade-prechecks.community"></a>

以下是 MySQL 5.7 和 8.0 之間不相容的一般清單：
+ 您的 MySQL 5.7 相容資料庫叢集不得使用 MySQL 8.0 中不支援的功能。

  如需詳細資訊，請參閱 MySQL 文件中的 [Features Removed in MySQL 8.0](https://dev.mysql.com/doc/refman/8.0/en/mysql-nutshell.html#mysql-nutshell-removals) (MySQL 8.0 中移除的功能)。
+ 不能違反關鍵字或保留字的規定。MySQL 8.0 中可能會保留一些先前未保留的關鍵字。

  如需詳細資訊，請參閱 MySQL 文件中的 [Keywords and Reserved Words](https://dev.mysql.com/doc/refman/8.0/en/keywords.html) (關鍵字與保留字)。
+ 運用 Unicode 增強支援時，請考慮將使用 `utf8mb3` 字元集的物件轉換成使用 `utf8mb4` 字元集，因為 `utf8mb3` 字元集已棄用。另外，`utf8mb4` 目前是 `utf8` 字元集的別名，因此請考慮使用 `utf8` 做為字元集參考，而不是 `utf8mb3`。

  如需詳細資訊，請參閱 MySQL 文件中的 [The utf8mb3 character set (3-byte UTF-8 unicode encoding)](https://dev.mysql.com/doc/refman/8.0/en/charset-unicode-utf8mb3.html)。
+ 不得有非預設資料列格式的 InnoDB 資料表。
+ 不得有 `ZEROFILL` 或 `display` 長度類型屬性。
+ 分割資料表所使用的儲存引擎皆需提供原生分割支援。
+ MySQL 5.7 `mysql` 系統資料庫中的資料表名稱不得與 MySQL 8.0 資料字典所使用的資料表名稱相同。
+ 資料表不能使用過時的資料類型或函數。
+ 外部索引鍵的限制條件名稱不得超過 64 個字元。
+ 不能在 `sql_mode` 系統變數設定中定義過時的 SQL 模式。
+ 資料表或預存程序的個別 `ENUM` 或 `SET` 資料欄元素長度皆不得超過 255 個字元。
+ 共用 InnoDB 資料表空間中不能存在資料表分割區。
+ 資料表空間資料檔案路徑中不得有循環參考。
+ 查詢和預存程式定義皆不得對 `ASC` 子句使用 `DESC` 或 `GROUP BY` 限定詞。
+ 不得移除任何系統變數，且系統變數必須使用 MySQL 8.0 的新預設值。
+ 日期、日期時間或時間戳記值不得為零 (`0`)。
+ 不得有因檔案移除或損毀所導致的結構描述不一致
+ 不得有任何包含 `FTS` 字元字串的資料表名稱。
+ 不得有任何屬於不同引擎的 InnoDB 資料表。
+ 不得有任何資料表或結構描述名稱對 MySQL 5.7 無效。

如需執行中預先檢查的詳細資訊，請參閱 [Aurora MySQL 的預先檢查描述參考](AuroraMySQL.upgrade-prechecks.descriptions.md)。

如需升級至 MySQL 8.0 的詳細資訊，請參閱 MySQL 文件中的 [Upgrading MySQL](https://dev.mysql.com/doc/refman/8.0/en/upgrading.html) (升級 MySQL)。如需 MySQL 8.0 中變更的一般說明，請參閱 MySQL 文件中的 [MySQL 8.0 中的新功能](https://dev.mysql.com/doc/refman/8.0/en/mysql-nutshell.html)。

## Aurora MySQL 升級預先檢查摘要
<a name="AuroraMySQL.upgrade-prechecks.ams"></a>

從第 2 版升級至第 3 版時，Aurora MySQL 有自己的特定需求，包括下列項目：
+ 在檢視、常式、觸發條件和事件中，不得有已棄用的 SQL 語法，例如 `SQL_CACHE`、`SQL_NO_CACHE` 和 `QUERY_CACHE`。
+ 任何沒有 `FTS` 索引的資料表上不得有 `FTS_DOC_ID` 欄。
+ InnoDB 資料字典與實際資料表定義之間不得有任何資料欄定義不相符。
+ `lower_case_table_names` 參數設定為 `1` 時，所有資料庫和資料表名稱都必須是小寫。
+ 事件和觸發條件不能有遺漏或空白的 DEFINER，或是無效的建立內容。
+ 資料庫中的所有觸發條件名稱都必須是唯一的。
+ Aurora MySQL 第 3 版不支援 DDL 復原和快速 DDL。資料庫中不得有與這些功能相關的成品。
+ 具有 `REDUNDANT` 或 `COMPACT` 資料列格式的資料表索引不能大於 767 個位元組。
+ 在 `tiny` 文字資料欄上定義的索引字首長度不能超過 255 個位元組。使用 `utf8mb4` 字元集時，這會將支援的字首長度限制為 63 個字元。

  使用 `innodb_large_prefix` 參數在 MySQL 5.7 中允許較大的字首長度。此參數已在 MySQL 8.0 中棄用。
+ `mysql.host` 資料表中不得有任何 InnoDB 中繼資料不一致。
+ 系統資料表中不得有任何資料欄資料類型不符。
+ `prepared` 狀態中不得有 XA 交易。
+ 檢視中的資料欄名稱不能超過 64 個字元。
+ 預存程序中的特殊字元不能不一致。
+ 資料表不能有資料檔案路徑不一致。

如需執行中預先檢查的詳細資訊，請參閱 [Aurora MySQL 的預先檢查描述參考](AuroraMySQL.upgrade-prechecks.descriptions.md)。

# Aurora MySQL 的預先檢查描述參考
<a name="AuroraMySQL.upgrade-prechecks.descriptions"></a>

此處詳細說明 Aurora MySQL 的升級預先檢查。

**Contents**
+ [錯誤](#precheck-descriptions-errors)
  + [報告錯誤的 MySQL 預先檢查](#precheck-descriptions-errors.mysql)
  + [Aurora MySQL 會預先檢查報告錯誤](#precheck-descriptions-errors.aurora)
+ [警告](#precheck-descriptions-warnings)
  + [報告警告的 MySQL 預先檢查](#precheck-descriptions-warnings.mysql)
  + [報告警告的 Aurora MySQL 預先檢查](#precheck-descriptions-warnings.aurora)
+ [注意](#precheck-descriptions-notices)
+ [錯誤、警告或通知](#precheck-descriptions-all)

## 錯誤
<a name="precheck-descriptions-errors"></a>

下列預先檢查會在預先檢查失敗且升級無法繼續時產生錯誤。

**Topics**
+ [報告錯誤的 MySQL 預先檢查](#precheck-descriptions-errors.mysql)
+ [Aurora MySQL 會預先檢查報告錯誤](#precheck-descriptions-errors.aurora)

### 報告錯誤的 MySQL 預先檢查
<a name="precheck-descriptions-errors.mysql"></a>

下列預先檢查來自 Community MySQL：
+ [checkTableMysqlSchema](#checkTableMysqlSchema)
+ [circularDirectoryCheck](#circularDirectoryCheck)
+ [columnsWhichCannotHaveDefaultsCheck](#columnsWhichCannotHaveDefaultsCheck)
+ [depreciatedSyntaxCheck](#depreciatedSyntaxCheck)
+ [engineMixupCheck](#engineMixupCheck)
+ [enumSetElementLengthCheck](#enumSetElementLengthCheck)
+ [foreignKeyLengthCheck](#foreignKeyLengthCheck)
+ [getDuplicateTriggers](#getDuplicateTriggers)
+ [getEventsWithNullDefiner](#getEventsWithNullDefiner)
+ [getMismatchedMetadata](#getMismatchedMetadata)
+ [getTriggersWithNullDefiner](#getTriggersWithNullDefiner)
+ [getValueOfVariablelower\$1case\$1table\$1names](#getValueOfVariable)
+ [groupByAscSyntaxCheck](#groupByAscSyntaxCheck)
+ [mysqlEmptyDotTableSyntaxCheck](#mysqlEmptyDotTableSyntaxCheck)
+ [mysqlIndexTooLargeCheck](#mysqlIndexTooLargeCheck)
+ [mysqlInvalid57NamesCheck](#mysqlInvalid57NamesCheck)
+ [mysqlOrphanedRoutinesCheck](#mysqlOrphanedRoutinesCheck)
+ [mysqlSchemaCheck](#mysqlSchemaCheck)
+ [nonNativePartitioningCheck](#nonNativePartitioningCheck)
+ [oldTemporalCheck](#oldTemporalCheck)
+ [partitionedTablesInSharedTablespaceCheck](#partitionedTablesInSharedTablespace)
+ [removedFunctionsCheck](#removedFunctionsCheck)
+ [routineSyntaxCheck](#routineSyntaxCheck)
+ [schemaInconsistencyCheck](#schemaInconsistencyCheck)

**checkTableMysqlSchema**  
**預先檢查層級：錯誤**  
**`mysql` 結構描述的 `check table x for upgrade` 命令所報告的問題**  
開始升級至 Aurora MySQL 第 3 版之前，`check table for upgrade` 會在資料庫執行個體 `mysql` 結構描述中的每個資料表上執行。`check table for upgrade` 命令會檢查資料表是否有任何在升級至較新版本的 MySQL 期間可能發生的潛在問題。在嘗試升級之前執行此命令有助於事先識別和解決任何不相容，使實際的升級程序更順暢。  
此命令會對每個資料表執行各種檢查，如下所示：  
+ 確認資料表結構和中繼資料是否與目標 MySQL 版本相容
+ 檢查資料表使用的任何已棄用或已移除的功能
+ 確保資料表可以正確升級，而不會遺失資料
如需詳細資訊，請參閱 MySQL 文件中的 [CHECK TABLE 陳述式](https://dev.mysql.com/doc/refman/5.7/en/check-table.html)。  
**輸出範例：**  

```
{
  "id": "checkTableMysqlSchema",
  "title": "Issues reported by 'check table x for upgrade' command for mysql schema.",
  "status": "OK",
  "detectedProblems": []
}
```
此預先檢查的輸出取決於遇到的錯誤，以及遇到的時間，因為 `check table for upgrade` 會執行多個檢查。  
如果您在此預先檢查中遇到任何錯誤，請向 [AWS Support](https://aws.amazon.com/support) 開立案例，以請求解決中繼資料不一致的問題。或者，您可以執行邏輯傾印，然後還原至新的 Aurora MySQL 第 3 版資料庫叢集，以重試升級。

**circularDirectoryCheck**  
**預先檢查層級：錯誤**  
**資料表空間資料檔案路徑中的循環目錄參考**  
從 [MySQL 8.0.17](https://dev.mysql.com/doc/relnotes/mysql/8.0/en/news-8-0-17.html) 開始，`CREATE TABLESPACE ... ADD DATAFILE` 子句不再允許循環目錄參考。為避免升級問題，請先從資料表空間資料檔案路徑移除任何循環目錄參考，再升級至 Aurora MySQL 第 3 版。  
**輸出範例：**  

```
{
  "id": "circularDirectory",
  "title": "Circular directory references in tablespace data file paths",
  "status": "OK",
  "description": "Error: Following tablespaces contain circular directory references (e.g. the reference '/../') in data file paths which as of MySQL 8.0.17 are not permitted by the CREATE TABLESPACE ... ADD DATAFILE clause. An exception to the restriction exists on Linux, where a circular directory reference is permitted if the preceding directory is a symbolic link. To avoid upgrade issues, remove any circular directory references from tablespace data file paths before upgrading.",
  "documentationLink": "https://dev.mysql.com/doc/refman/8.0/en/upgrading-from-previous-series.html#upgrade-innodb-changes",
  "detectedProblems": [
      {
        "level": "Error",
        "dbObject": "ts2",
        "description": "circular reference in datafile path: '/home/ec2-user/dbdata/mysql_5_7_44/../ts2.ibd'",
        "dbObjectType": "Tablespace"
      }
  ]
}
```
如果您收到此錯誤，請使用 [file-per-table 資料表空間](https://dev.mysql.com/doc/refman/8.0/en/innodb-file-per-table-tablespaces.html)重建資料表。對所有資料表空間和資料表定義使用預設檔案路徑。  
Aurora MySQL 不支援一般資料表空間或 `CREATE TABLESPACE` 命令。  
在重建資料表空間之前，請參閱 MySQL 文件中的[線上 DDL 操作](https://dev.mysql.com/doc/refman/5.7/en/innodb-online-ddl-operations.html)，以了解鎖定和資料移動對前景交易的影響。
重建後，預先檢查會通過，允許升級繼續進行。  

```
{
  "id": "circularDirectoryCheck",
  "title": "Circular directory references in tablespace data file paths",
  "status": "OK",
  "detectedProblems": []
},
```

**columnsWhichCannotHaveDefaultsCheck**  
**預先檢查層級：錯誤**  
**無法具有預設值的資料欄**  
在 MySQL 8.0.13 之前，`BLOB`、`GEOMETRY`、`TEXT` 和 `JSON` 資料欄不能有[預設值](https://dev.mysql.com/doc/refman/5.7/en/data-type-defaults.html)。在升級至 Aurora MySQL 第 3 版之前，請移除這些資料欄上的任何預設子句。如需這些資料類型預設處理方式變更的詳細資訊，請參閱 MySQL 文件中的[資料類型預設值](https://dev.mysql.com/doc/refman/8.0/en/data-type-defaults.html)。  
**輸出範例：**  

```
{
  "id": "columnsWhichCannotHaveDefaultsCheck",
  "title": "Columns which cannot have default values",
  "status": "OK",
  "description": "Error: The following columns are defined as either BLOB, TEXT, GEOMETRY or JSON and have a default value set. These data types cannot have default values in MySQL versions prior to 8.0.13, while starting with 8.0.13, the default value must be specified as an expression. In order to fix this issue, please use the ALTER TABLE ... ALTER COLUMN ... DROP DEFAULT statement.",
  "documentationLink": "https://dev.mysql.com/doc/refman/8.0/en/data-type-defaults.html#data-type-defaults-explicit",
  "detectedProblems": [
      {
        "level": "Error",
        "dbObject": "test.test_blob_default.geo_col",
        "description": "geometry"
      }
  ]
},
```
預先檢查會傳回錯誤，因為 `test.test_blob_default` 資料表中的 `geo_col` 欄使用具有指定預設值的 `BLOB`、`GEOMETRY`、`TEXT` 或 `JSON` 資料類型。  
查看資料表定義，我們可以看到 `geo_col` 欄定義為 `geo_col geometry NOT NULL default ''`。  

```
mysql> show create table test_blob_default\G
*************************** 1. row ***************************
       Table: test_blob_default
Create Table: CREATE TABLE `test_blob_default` (
  `geo_col` geometry NOT NULL DEFAULT ''
) ENGINE=InnoDB DEFAULT CHARSET=latin1
```
移除此預設子句以允許預先檢查通過。  
在執行 `ALTER TABLE` 陳述式或重建資料表空間之前，請參閱 MySQL 文件中的[線上 DDL 操作](https://dev.mysql.com/doc/refman/5.7/en/innodb-online-ddl-operations.html)，以了解鎖定和資料移動對前景交易的影響。

```
mysql> ALTER TABLE test_blob_default modify COLUMN geo_col geometry NOT NULL;
Query OK, 0 rows affected (0.02 sec)
Records: 0  Duplicates: 0  Warnings: 0

mysql> show create table test_blob_default\G
*************************** 1. row ***************************
       Table: test_blob_default
Create Table: CREATE TABLE `test_blob_default` (
  `geo_col` geometry NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1
1 row in set (0.00 sec)
```
預先檢查通過，您可以重試升級。  

```
{
  "id": "columnsWhichCannotHaveDefaultsCheck",
  "title": "Columns which cannot have default values",
  "status": "OK",
  "detectedProblems": []
},
```

**depreciatedSyntaxCheck**  
**預先檢查層級：錯誤**  
**定義中已棄用關鍵字的使用**  
MySQL 8.0 已移除[查詢快取](https://dev.mysql.com/doc/refman/5.7/en/query-cache.html)。因此，某些查詢快取特定的 SQL 語法已移除。如果您的任何資料庫物件包含 `QUERY CACHE`、`SQL_CACHE` 或 `SQL_NO_CACHE` 關鍵字，則會傳回預先檢查錯誤。若要解決此問題，請重新建立這些物件，移除提及的關鍵字。  
**輸出範例：**  

```
{
  "id": "depreciatedSyntaxCheck",
  "title": "Usage of depreciated keywords in definition",
  "status": "OK",
  "description": "Error: The following DB objects contain keywords like 'QUERY CACHE', 'SQL_CACHE', 'SQL_NO_CACHE' which are not supported in major version 8.0. It is recommended to drop these DB objects or rebuild without any of the above keywords before upgrade.",
  "detectedProblems": [
      {
"level": "Error",
"dbObject": "test.no_query_cache_check",
"description": "PROCEDURE uses depreciated words in definition"
      }
  ]
}
```
預先檢查會報告 `test.no_query_cache_check` 預存程序正在使用其中一個已移除的關鍵字。查看程序定義，我們可以看到它使用 `SQL_NO_CACHE`。  

```
mysql> show create procedure test.no_query_cache_check\G
*************************** 1. row ***************************
           Procedure: no_query_cache_check
            sql_mode:
    Create Procedure: CREATE DEFINER=`reinvent`@`%` PROCEDURE `no_query_cache_check`()
BEGIN
    SELECT SQL_NO_CACHE k from sbtest1 where id > 10 and id < 20 group by k asc;
END
character_set_client: utf8mb4
collation_connection: utf8mb4_0900_ai_ci
  Database Collation: latin1_swedish_ci
1 row in set (0.00 sec)
```
移除關鍵字。  

```
mysql> drop procedure test.no_query_cache_check;
Query OK, 0 rows affected (0.01 sec)

mysql> delimiter //

mysql> CREATE DEFINER=`reinvent`@`%` PROCEDURE `no_query_cache_check`() BEGIN     SELECT k from sbtest1 where id > 10 and id < 20 group by k asc; END//
Query OK, 0 rows affected (0.00 sec)

mysql> delimiter ;
```
移除關鍵字後，預先檢查會成功完成。  

```
{
  "id": "depreciatedSyntaxCheck",
  "title": "Usage of depreciated keywords in definition",
  "status": "OK",
  "detectedProblems": []
}
```

**engineMixupCheck**  
**預先檢查層級：錯誤**  
**InnoDB 辨識屬於不同引擎的資料表**  
與 [schemaInconsistencyCheck](#schemaInconsistencyCheck) 類似，此預先檢查會先確認 MySQL 中的資料表中繼資料是否一致，再繼續升級。  
如果您在此預先檢查中遇到任何錯誤，請向 [AWS Support](https://aws.amazon.com/support) 開立案例，以請求解決中繼資料不一致的問題。或者，您可以執行邏輯傾印，然後還原至新的 Aurora MySQL 第 3 版資料庫叢集，以重試升級。  
**輸出範例：**  

```
{
  "id": "engineMixupCheck",
  "title": "Tables recognized by InnoDB that belong to a different engine",
  "status": "OK",
  "description": "Error: Following tables are recognized by InnoDB engine while the SQL layer believes they belong to a different engine. Such situation may happen when one removes InnoDB table files manually from the disk and creates e.g. a MyISAM table with the same name.\n\nA possible way to solve this situation is to e.g. in case of MyISAM table:\n\n1. Rename the MyISAM table to a temporary name (RENAME TABLE).\n2. Create some dummy InnoDB table (its definition does not need to match), then copy (copy, not move) and rename the dummy .frm and .ibd files to the orphan name using OS file commands.\n3. The orphan table can be then dropped (DROP TABLE), as well as the dummy table.\n4. Finally the MyISAM table can be renamed back to its original name.",
  "detectedProblems": [
      {
        "level": "Error",
        "dbObject": "mysql.general_log_backup",
        "description": "recognized by the InnoDB engine but belongs to CSV"
      }
  ]
}
```

**enumSetElementLengthCheck**  
**預先檢查層級：錯誤**  
**`ENUM` 和 `SET` 欄定義包含超過 255 個字元的元素**  
資料表和預存程序的 `ENUM` 或 `SET` 欄元素不得超過 255 個字元或 1020 位元組。在 MySQL 8.0 之前，合併長度上限為 64K，但 8.0 會將個別元素限制為 255 個字元或 1020 個位元組 (支援多位元組)。如果您收到 `enumSetElementLengthCheck` 的預先檢查失敗，請在重試升級之前修改任何超過這些新限制的元素。  
**輸出範例：**  

```
{
  "id": "enumSetElementLengthCheck",
  "title": "ENUM/SET column definitions containing elements longer than 255 characters",
  "status": "OK",
  "description": "Error: The following columns are defined as either ENUM or SET and contain at least one element longer that 255 characters. They need to be altered so that all elements fit into the 255 characters limit.",
  "documentationLink": "https://dev.mysql.com/doc/refman/8.0/en/string-type-overview.html",
  "detectedProblems": [
      {
        "level": "Error",
        "dbObject": "test.large_set.s",
        "description": "SET contains element longer than 255 characters"
      }
  ]
},
```
預先檢查會報告錯誤，因為 `test.large_set` 資料表中的 `s` 欄包含大於 255 個字元的 `SET` 元素。  
減少此欄的 `SET` 大小後，預先檢查會通過，讓升級繼續進行。  

```
{
  "id": "enumSetElementLenghtCheck",
  "title": "ENUM/SET column definitions containing elements longer than 255 characters",
  "status": "OK",
  "detectedProblems": []
},
```

**foreignKeyLengthCheck**  
**預先檢查層級：錯誤**  
**外部索引鍵的限制條件名稱超過 64 個字元。**  
在 MySQL 中，識別符的長度限制為 64 個字元，如 [MySQL 文件](https://dev.mysql.com/doc/refman/8.0/en/identifier-length.html)所述。由於發現外部索引鍵長度可能等於或超過此值的[問題](https://bugs.mysql.com/bug.php?id=88118)，導致升級失敗，因此已實作此預先檢查。如果此預先檢查發生錯誤，您應該[變更或重新命名](https://dev.mysql.com/doc/refman/8.0/en/alter-table.html)限制條件，使其在重試升級之前少於 64 個字元。  
**輸出範例：**  

```
{
  "id": "foreignKeyLength",
  "title": "Foreign key constraint names longer than 64 characters",
  "status": "OK",
  "detectedProblems": []
}
```

**getDuplicateTriggers**  
**預先檢查層級：錯誤**  
**資料庫中的所有觸發條件名稱必須是唯一的。**  
由於資料字典實作的變更，MySQL 8.0 不支援資料庫中區分大小寫的觸發條件。此預先檢查會確認您的資料庫叢集沒有一或多個包含重複觸發條件的資料庫。如需詳細資訊，請參閱 MySQL 文件中的[識別符區分大小寫](https://dev.mysql.com/doc/refman/8.0/en/identifier-case-sensitivity.html)。  
**輸出範例：**  

```
{
  "id": "getDuplicateTriggers",
  "title": "MySQL pre-checks that all trigger names in a database are unique or not.",
  "status": "OK",
  "description": "Error: You have one or more database containing duplicate triggers. Mysql 8.0 does not support case sensitive triggers within a database https://dev.mysql.com/doc/refman/8.0/en/identifier-case-sensitivity.html. To upgrade to MySQL 8.0, drop the triggers with case-insensitive duplicate names and recreate with distinct names.",
  "detectedProblems": [
      {
        "level": "Error",
        "dbObject": "test",
        "description": "before_insert_product"
      },
      {
        "level": "Error",
        "dbObject": "test",
        "description": "before_insert_PRODUCT"
      }
  ]
}
```
預先檢查會報告錯誤，指出資料庫叢集有兩個具有相同名稱的觸發條件，但使用不同的案例：`test.before_insert_product` 和 `test.before_insert_PRODUCT`。  
升級之前，請重新命名觸發條件或捨棄，然後使用新名稱重新建立觸發條件。  
將 `test.before_insert_PRODUCT` 重新命名為 `test.before_insert_product_2` 後，預先檢查會成功。  

```
{
  "id": "getDuplicateTriggers",
  "title": "MySQL pre-checks that all trigger names in a database are unique or not.",
  "status": "OK",
  "detectedProblems": []
}
```

**getEventsWithNullDefiner**  
**預先檢查層級：錯誤**  
**`mysql.event` 的定義程式資料欄不能為 null 或空白。**  
`DEFINER` 屬性會指定擁有預存物件定義的 MySQL 帳戶，例如觸發條件、預存程序或事件。此屬性在您想要控制預存物件執行所在安全性內容的情況下特別有用。建立存放的物件時，如果 `DEFINER` 未指定 ，則預設值為建立物件的使用者。  
升級至 MySQL 8.0 時，您無法在 MySQL 資料字典中有任何具有 `null` 或空白定義程式的預存物件。如果您有此類預存物件，則會引發預先檢查錯誤。您必須先修正此問題，才能繼續升級。  
錯誤範例：  

```
{
  "id": "getEventsWithNullDefiner",
  "title": "The definer column for mysql.event cannot be null or blank.",
  "status": "OK",
  "description": "Error: Set definer column in mysql.event to a valid non-null definer.",
  "detectedProblems": [
      {
        "level": "Error",
        "dbObject": "test.get_version",
        "description": "Set definer for event get_version in Schema test"
      }
  ]
}
```
預先檢查會傳回 `test.get_version` [事件](https://dev.mysql.com/doc/refman/5.7/en/events-overview.html)的錯誤，因為它具有 `null` 定義程式。  
若要解決此問題，您可以檢查事件定義。如您所見，定義程式為 `null` 或空白。  

```
mysql> select db,name,definer from mysql.event where name='get_version';
+------+-------------+---------+
| db   | name        | definer |
+------+-------------+---------+
| test | get_version |         |
+------+-------------+---------+
1 row in set (0.00 sec)
```
捨棄或重新建立具有有效定義程式的事件。  
在捨棄或重新定義 `DEFINER` 之前，請仔細檢閱並檢查您的應用程式和權限需求。如需詳細資訊，請參閱 MySQL 文件中的[預存物件存取控制](https://dev.mysql.com/doc/refman/5.7/en/stored-objects-security.html)。

```
mysql> drop event test.get_version;
Query OK, 0 rows affected (0.00 sec)

mysql> DELIMITER ;
mysql> delimiter $$
mysql> CREATE EVENT get_version
    ->     ON SCHEDULE
    ->       EVERY 1 DAY
    ->     DO
    ->      ///DO SOMETHING //
    -> $$
Query OK, 0 rows affected (0.01 sec)

mysql> DELIMITER ;

mysql> select db,name,definer from mysql.event where name='get_version';
+------+-------------+------------+
| db   | name        | definer    |
+------+-------------+------------+
| test | get_version | reinvent@% |
+------+-------------+------------+
1 row in set (0.00 sec)
```
現在，預先檢查通過了。  

```
{
  "id": "getEventsWithNullDefiner",
  "title": "The definer column for mysql.event cannot be null or blank.",
  "status": "OK",
  "detectedProblems": []},
```

**getMismatchedMetadata**  
**預先檢查層級：錯誤**  
**InnoDB 資料字典和實際資料表定義之間的資料欄定義不相符**  
與 [schemaInconsistencyCheck](#schemaInconsistencyCheck) 類似，此預先檢查會先確認 MySQL 中的資料表中繼資料是否一致，再繼續升級。在此情況下，預先檢查會確認 InnoDB 資料字典和 MySQL 資料表定義之間的資料欄定義是否相符。如果偵測到不相符，則升級不會繼續。  
如果您在此預先檢查中遇到任何錯誤，請向 [AWS Support](https://aws.amazon.com/support) 開立案例，以請求解決中繼資料不一致的問題。或者，您可以執行邏輯傾印，然後還原至新的 Aurora MySQL 第 3 版資料庫叢集，以重試升級。  
**輸出範例：**  

```
{
  "id": "getMismatchedMetadata",
  "title": "Column definition mismatch between InnoDB Data Dictionary and actual table definition.",
  "status": "OK",
  "description": "Error: Your database has mismatched metadata. The upgrade to mysql 8.0 will not succeed until this is fixed.",
  "detectedProblems": [
      {
        "level": "Error",
        "dbObject": "test.mismatchTable",
        "description": "Table `test/mismatchTable` column names mismatch with InnoDb dictionary column names: iD <> id"
      }
  ]
}
```
預先檢查會報告 `test.mismatchTable` 資料表中 `id` 欄的中繼資料不相符。具體而言，MySQL 中繼資料的資料欄名稱為 `iD`，而 InnoDB 的資料欄名稱則為 `id`。

**getTriggersWithNullDefiner**  
**預先檢查層級：錯誤**  
**`information_schema.triggers` 的定義程式資料欄不能為 `null` 或空白。**  
預先檢查會確認您的資料庫沒有使用 `null` 或空白定義程式定義的觸發條件。如需預存物件定義程式需求的詳細資訊，請參閱 [getEventsWithNullDefiner](#getEventsWithNullDefiner)。  
**輸出範例：**  

```
{
  "id": "getTriggersWithNullDefiner",
  "title": "The definer column for information_schema.triggers cannot be null or blank.",
  "status": "OK",
  "detectedProblems": [
      {
        "level": "Error",
        "dbObject": "test.example_trigger",
        "description": "Set definer for trigger example_trigger in Schema test"
      }
  ]
}
```
預先檢查會傳回錯誤，因為 `test` 結構描述中的 `example_trigger` 觸發條件具有 `null` 定義程式。若要修正此問題，請使用有效的使用者重新建立觸發條件，或捨棄觸發條件，以修正定義程式。如需詳細資訊，請參閱 [getEventsWithNullDefiner](#getEventsWithNullDefiner) 中的範例。  
在捨棄或重新定義 `DEFINER` 之前，請仔細檢閱並檢查您的應用程式和權限需求。如需詳細資訊，請參閱 MySQL 文件中的[預存物件存取控制](https://dev.mysql.com/doc/refman/5.7/en/stored-objects-security.html)。

**getValueOfVariablelower\$1case\$1table\$1names**  
**預先檢查層級：錯誤**  
**`lower_case_table_names` 參數設定為 `1` 時，所有資料庫或資料表名稱都必須是小寫。**  
在 MySQL 8.0 之前，資料庫名稱、資料表名稱和其他物件會對應至資料目錄中的檔案，例如檔案型中繼資料 (.frm)。[lower\$1case\$1table\$1names](https://dev.mysql.com/doc/refman/5.7/en/identifier-case-sensitivity.html) 系統變數可讓使用者控制伺服器如何處理資料庫物件的識別符區分大小寫，以及儲存此類中繼資料物件。重新啟動後，可以在已初始化的伺服器上變更此參數。  
不過，在 MySQL 8.0 中，雖然此參數仍然控制伺服器如何處理識別符大小寫的區分性，但在資料字典初始化後就無法變更。升級或建立 MySQL 8.0 資料庫時，資料字典第一次在 MySQL 上啟動時針對 `lower_case_table_names` 所設定的值會用於該資料庫的生命週期。此限制是實作[單元資料字典](https://dev.mysql.com/doc/refman/8.0/en/data-dictionary-file-removal.html)實作的一部分，其中資料庫物件會從檔案型中繼資料遷移到 `mysql` 結構描述中的內部 InnoDB 資料表。  
如需詳細資訊，請參閱 MySQL 文件中的[資料字典變更](https://dev.mysql.com/doc/refman/8.0/en/upgrading-from-previous-series.html#upgrade-data-dictionary-changes)。  
為了避免在升級期間將檔案型中繼資料更新為新的單元資料字典時發生問題，此預先檢查會驗證在 `lower_case_table_names = 1` 時，所有資料表都會以小寫儲存在磁碟上。如果沒有，則會傳回預先檢查錯誤，而且您必須先修正中繼資料，才能繼續升級。  
**輸出範例：**  

```
{
  "id": "getValueOfVariablelower_case_table_names",
  "title": "MySQL pre-checks that all database or table names are lowercase when the lower_case_table_names parameter is set to 1.",
  "status": "OK",
  "description": "Error: You have one or more databases or tables with uppercase letters in the names, but the lower_case_table_names parameter is set to 1. To upgrade to MySQL 8.0, either change all database or table names to lowercase, or set the parameter to 0.",
  "detectedProblems": [
      {
        "level": "Error",
        "dbObject": "test.TEST",
        "description": "Table test.TEST contains one or more capital letters in name while lower_case_table_names = 1"
      }
  ]
}
```
因為資料表 `test.TEST` 包含大寫字母，但 `lower_case_table_names` 設定為 `1`，所以傳回錯誤。  
若要解決此問題，您可以重新命名資料表以使用小寫，或修改資料庫叢集上的 `lower_case_table_names` 參數，然後再開始升級。  
仔細測試和檢閱 MySQL 中[區分大小寫](https://dev.mysql.com/doc/refman/5.7/en/identifier-case-sensitivity.html)的文件，以及任何此類變更如何影響您的應用程式。  
另請檢閱 MySQL 8.0 文件，了解如何在 MySQL 8.0 中以不同方式處理 [lower\$1case\$1table\$1names](https://dev.mysql.com/doc/refman/8.0/en/server-system-variables.html#sysvar_lower_case_table_names)。

**groupByAscSyntaxCheck**  
**預先檢查層級：錯誤**  
**已移除 `GROUP BY ASC/DESC` 語法的使用**  
從 MySQL 8.0.13 開始，已移除 `GROUP BY` 子句的已棄用 `ASC` 或 `DESC` 語法。依賴 `GROUP BY` 排序的查詢現在可能會產生不同的結果。若要取得特定的排序順序，請改用 `ORDER BY` 子句。如果資料庫中有任何物件使用此語法，您必須在重試升級之前，使用 `ORDER BY` 子句重新建立物件。如需更多詳細資訊，請參閱 MySQL 文件中的 [SQL 變更](https://dev.mysql.com/doc/refman/8.0/en/upgrading-from-previous-series.html#upgrade-sql-changes)。  
**輸出範例：**  

```
{
  "id": "groupbyAscSyntaxCheck",
  "title": "Usage of removed GROUP BY ASC/DESC syntax",
  "status": "OK",
  "description": "Error: The following DB objects use removed GROUP BY ASC/DESC syntax. They need to be altered so that ASC/DESC keyword is removed from GROUP BY clause and placed in appropriate ORDER BY clause.",
  "documentationLink": "https://dev.mysql.com/doc/relnotes/mysql/8.0/en/news-8-0-13.html#mysqld-8-0-13-sql-syntax",
  "detectedProblems": [
      {
        "level": "Error",
        "dbObject": "test.groupbyasc",
        "description": "PROCEDURE uses removed GROUP BY ASC syntax",
        "dbObjectType": "Routine"
      }
  ]
}
```

**mysqlEmptyDotTableSyntaxCheck**  
**預先檢查層級：錯誤**  
**檢查常式中使用的已棄用 `.<table>` 語法。**  
在 MySQL 8.0 中，常式無法再包含已棄用的識別符語法 (`\".<table>\"`)。如果任何預存常式或觸發條件包含此類識別符，則升級會失敗。例如，不再允許下列 `.dot_table` 參考：  

```
mysql> show create procedure incorrect_procedure\G
*************************** 1. row ***************************
           Procedure: incorrect_procedure
            sql_mode:
    Create Procedure: CREATE DEFINER=`reinvent`@`%` PROCEDURE `incorrect_procedure`()
BEGIN delete FROM .dot_table; select * from .dot_table where 1=1; END
character_set_client: utf8mb4
collation_connection: utf8mb4_0900_ai_ci
  Database Collation: latin1_swedish_ci
1 row in set (0.00 sec)
```
重新建立常式和觸發程序以使用正確的識別符語法和逸出之後，預先檢查會通過，而且升級可以繼續進行。如需詳細資訊，請參閱 PostgreSQL 文件中的[結構描述物件名稱](https://dev.mysql.com/doc/refman/8.0/en/identifiers.html)。  
**輸出範例：**  

```
{
  "id": "mysqlEmptyDotTableSyntaxCheck",
  "title": "Check for deprecated '.<table>' syntax used in routines.",
  "status": "OK",
  "description": "Error: The following routines contain identifiers in deprecated identifier syntax (\".<table>\"), and should be corrected before upgrade:\n",
  "detectedProblems": [
      {
        "level": "Error",
        "dbObject": "test.incorrect_procedure",
        "description": " routine body contains deprecated identifiers."
      }
  ]
}
```
預先檢查會傳回 `test` 資料庫中 `incorrect_procedure` 常式的錯誤，因為它包含已棄用的語法。  
修正常式後，預先檢查會成功，您可以重試升級。

**mysqlIndexTooLargeCheck**  
**預先檢查層級：錯誤**  
**檢查索引是否太大而無法在高於 5.7 的 MySQL 版本上運作**  
對於精簡或備援資料列格式，不應能夠建立字首大於 767 個位元組的索引。不過，在 MySQL 5.7.35 版之前，這是可能的。如需詳細資訊，請參閱 [MySQL 5.7.35 版本備註](https://dev.mysql.com/doc/relnotes/mysql/5.7/en/news-5-7-35.html)。  
升級到 MySQL 8.0 後，任何受此錯誤影響的索引都將無法存取。此預先檢查會識別必須在允許升級繼續之前重建的違規索引。  

```
 {
  "id": "mysqlIndexTooLargeCheck",
  "title": "Check for indexes that are too large to work on higher versions of MySQL Server than 5.7",
  "status": "OK",
  "description": "Error: The following indexes ware made too large for their format in an older version of MySQL (older than 5.7.34). Normally those indexes within tables with compact or redundant row formats shouldn't be larger than 767 bytes. To fix this problem those indexes should be dropped before upgrading or those tables will be inaccessible.",
  "detectedProblems": [
      {
        "level": "Error",
        "dbObject": "test.table_with_large_idx",
        "description": "IDX_2"
      }
  ]
}
```
預先檢查會傳回錯誤，因為 `test.table_with_large_idx` 資料表包含資料表上的索引，其使用大於 767 個位元組的精簡或備援資料列格式。升級到 MySQL 8.0 後，這些資料表將變得無法存取。在繼續升級之前，請執行下列其中一項操作：  
+ 捨棄預先檢查中提及的索引。
+ 新增預先檢查中提及的索引。
+ 變更資料表所使用的資料列格式。
在這裡，我們會重建資料表以解決預先檢查失敗。在重建資料表之前，請確定 [innodb\$1file\$1format](https://dev.mysql.com/doc/refman/5.7/en/innodb-parameters.html#sysvar_innodb_file_format) 設定為 `Barracuda`，且 [innodb\$1default\$1row\$1format](https://dev.mysql.com/doc/refman/5.7/en/innodb-parameters.html#sysvar_innodb_default_row_format) 設定為 `dynamic`。這些是 MySQL 5.7 中的預設值。如需詳細資訊，請參閱 MySQL 文件中的 [InnoDB 資料列格式](https://dev.mysql.com/doc/refman/5.7/en/innodb-row-format.html)和 [InnoDB 檔案格式管理](https://dev.mysql.com/doc/refman/5.7/en/innodb-file-format.html)。  
在重建資料表空間之前，請參閱 MySQL 文件中的[線上 DDL 操作](https://dev.mysql.com/doc/refman/5.7/en/innodb-online-ddl-operations.html)，以了解鎖定和資料移動對前景交易的影響。

```
mysql > select @@innodb_file_format,@@innodb_default_row_format;
+----------------------+-----------------------------+
| @@innodb_file_format | @@innodb_default_row_format |
+----------------------+-----------------------------+
| Barracuda            | dynamic                     |
+----------------------+-----------------------------+
1 row in set (0.00 sec)

mysql> optimize table table_with_large_idx;
+---------------------------+----------+----------+-------------------------------------------------------------------+
| Table                     | Op       | Msg_type | Msg_text                                                          |
+---------------------------+----------+----------+-------------------------------------------------------------------+
| test.table_with_large_idx | optimize | note     | Table does not support optimize, doing recreate + analyze instead |
| test.table_with_large_idx | optimize | status   | OK                                                                |
+---------------------------+----------+----------+-------------------------------------------------------------------+
2 rows in set (0.02 sec)

# Verify FILE_FORMAT and ROW_FORMAT
mysql>  select * from information_schema.innodb_sys_tables where name like 'test/table_with_large_idx';
+----------+---------------------------+------+--------+-------+-------------+------------+---------------+------------+
| TABLE_ID | NAME                      | FLAG | N_COLS | SPACE | FILE_FORMAT | ROW_FORMAT | ZIP_PAGE_SIZE | SPACE_TYPE |
+----------+---------------------------+------+--------+-------+-------------+------------+---------------+------------+
|       43 | test/table_with_large_idx |   33 |      4 |    26 | Barracuda   | Dynamic    |             0 | Single     |
+----------+---------------------------+------+--------+-------+-------------+------------+---------------+------------+
1 row in set (0.00 sec)
```
重建資料表後，預先檢查會通過，而且升級可以繼續。  

```
{
  "id": "mysqlIndexTooLargeCheck",
  "title": "Check for indexes that are too large to work on higher versions of MySQL Server than 5.7",
  "status": "OK",
  "detectedProblems": []
},
```

**mysqlInvalid57NamesCheck**  
**預先檢查層級：錯誤**  
**檢查 MySQL 5.7 中使用的無效資料表和結構描述名稱**  
遷移至 MySQL 8.0 中的新資料字典時，您的資料庫執行個體不能包含字首為 `#mysql50#` 的結構描述或資料表。如果有任何此類物件存在，則升級會失敗。若要解決此問題，請針對傳回的結構描述和資料表執行 [mysqlcheck](https://dev.mysql.com/doc/refman/8.0/en/mysqlcheck.html)。  
請務必使用 [MySQL 5.7 版本](https://downloads.mysql.com/archives/community/)的 `mysqlcheck`，因為 [--fix-db-names](https://dev.mysql.com/doc/refman/5.7/en/mysqlcheck.html#option_mysqlcheck_fix-db-names) 和 [--fix-table-names](https://dev.mysql.com/doc/refman/5.7/en/mysqlcheck.html#option_mysqlcheck_fix-table-names) 已從 [MySQL 8.0](https://dev.mysql.com/doc/refman/8.0/en/mysql-nutshell.html) 中移除。
**輸出範例：**  

```
{
  "id": "mysqlInvalid57NamesCheck",
  "title": "Check for invalid table names and schema names used in 5.7",
  "status": "OK",
  "description": "The following tables and/or schemas have invalid names. In order to fix them use the mysqlcheck utility as follows:\n\n  $ mysqlcheck --check-upgrade --all-databases\n  $ mysqlcheck --fix-db-names --fix-table-names --all-databases\n\nOR via mysql client, for eg:\n\n  ALTER DATABASE `#mysql50#lost+found` UPGRADE DATA DIRECTORY NAME;",
  "documentationLink": "https://dev.mysql.com/doc/refman/5.7/en/identifier-mapping.html https://dev.mysql.com/doc/refman/5.7/en/alter-database.html https://dev.mysql.com/doc/refman/8.0/en/mysql-nutshell.html#mysql-nutshell-removals",
  "detectedProblems": [
      {
        "level": "Error",
        "dbObject": "#mysql50#fix_db_names",
        "description": "Schema name"
      }
  ]
}
```
預先檢查會報告結構描述 `#mysql50#fix_db_names` 的名稱無效。  
修正結構描述名稱後，預先檢查會通過，允許升級繼續進行。  

```
{
  "id": "mysqlInvalid57NamesCheck",
  "title": "Check for invalid table names and schema names used in 5.7",
  "status": "OK",
  "detectedProblems": []
},
```

**mysqlOrphanedRoutinesCheck**  
**預先檢查層級：錯誤**  
**檢查 5.7 中的孤立常式**  
遷移至 MySQL 8.0 中的新資料字典時，如果資料庫中有任何預存程序不再存在結構描述，則升級會失敗。此預先檢查會確認資料庫執行個體上預存程序中參考的所有結構描述是否仍然存在。若要允許繼續升級，請捨棄這些預存程序。  
**輸出範例：**  

```
{
  "id": "mysqlOrphanedRoutinesCheck",
  "title": "Check for orphaned routines in 5.7",
  "status": "OK",
  "description": "Error: The following routines have been orphaned. Schemas that they are referencing no longer exists.\nThey have to be cleaned up or the upgrade will fail.",
  "detectedProblems": [
      {
        "level": "Error",
        "dbObject": "dropped_db.get_version",
        "description": "is orphaned"
      }
  ]
},
```
預先檢查會報告 `dropped_db` 資料庫中的 `get_version` 預存程序是孤立的。  
若要清除此程序，您可以重新建立缺少的結構描述。  

```
mysql> create database dropped_db;
Query OK, 1 row affected (0.01 sec)
```
重新建立結構描述之後，您可以捨棄該程序，以允許升級繼續進行。  

```
{
  "id": "mysqlOrphanedRoutinesCheck",
  "title": "Check for orphaned routines in 5.7",
  "status": "OK",
  "detectedProblems": []
},
```

**mysqlSchemaCheck**  
**預先檢查層級：錯誤**  
**`mysql` 結構描述中的資料表名稱與 MySQL 8.0 中的新資料表衝突**  
MySQL 8.0 中引入的新[單元資料字典](https://dev.mysql.com/doc/refman/8.0/en/data-dictionary-file-removal.html)會將所有中繼資料存放在 `mysql` 結構描述中的一組內部 InnoDB 資料表中。在升級期間，系統會在 `mysql` 結構描述中建立新的[內部資料字典資料表](https://dev.mysql.com/doc/refman/8.0/en/data-dictionary-schema.html)。為了避免導致升級失敗的命名衝突，預先檢查會檢查 `mysql` 結構描述中的所有資料表名稱，以確保沒有任何新的資料表名稱已在使用中。如果是，則會傳回錯誤，而且不允許繼續升級。  
**輸出範例：**  

```
{
  "id": "mysqlSchema",
  "title": "Table names in the mysql schema conflicting with new tables in the latest MySQL.",
  "status": "OK",
  "description": "Error: The following tables in mysql schema have names that will conflict with the ones introduced in the latest version. They must be renamed or removed before upgrading (use RENAME TABLE command). This may also entail changes to applications that use the affected tables.",
  "documentationLink": "https://dev.mysql.com/doc/refman/8.0/en/upgrade-before-you-begin.html",
  "detectedProblems": [
      {
        "level": "Error",
        "dbObject": "mysql.tablespaces",
        "description": "Table name used in mysql schema.",
        "dbObjectType": "Table"
      }
  ]
}
```
因為 `mysql` 結構描述中有名為 `tablespaces` 的資料表，所以傳回錯誤。這是 MySQL 8.0 中新的內部資料字典資料表名稱之一。您必須在升級之前使用 `RENAME TABLE` 命令重新命名或移除任何此類資料表。

**nonNativePartitioningCheck**  
**預先檢查層級：錯誤**  
**使用具有非原生分割之引擎的分割資料表**  
根據 [MySQL 8.0 文件](https://dev.mysql.com/doc/refman/8.0/en/mysql-nutshell.html)，兩個儲存引擎目前提供原生分割支援：[InnoDB](https://dev.mysql.com/doc/refman/8.0/en/innodb-storage-engine.html) 和 [NDB](https://dev.mysql.com/doc/refman/8.0/en/mysql-cluster.html)。其中，Aurora MySQL 第 3 版僅支援 InnoDB，與 MySQL 8.0 相容。使用任何其他儲存引擎在 MySQL 8.0 中建立分割資料表的任何嘗試都會失敗。此預先檢查會在資料庫叢集中尋找使用非原生分割的資料表。如果傳回任何結果，您必須移除分割或將儲存引擎轉換為 InnoDB。  
**輸出範例：**  

```
{
  "id": "nonNativePartitioning",
  "title": "Partitioned tables using engines with non native partitioning",
  "status": "OK",
  "description": "Error: In the latest MySQL storage engine is responsible for providing its own partitioning handler, and the MySQL server no longer provides generic partitioning support. InnoDB and NDB are the only storage engines that provide a native partitioning handler that is supported in the latest MySQL. A partitioned table using any other storage engine must be altered—either to convert it to InnoDB or NDB, or to remove its partitioning—before upgrading the server, else it cannot be used afterwards.",
  "documentationLink": "https://dev.mysql.com/doc/refman/8.0/en/upgrading-from-previous-series.html#upgrade-configuration-changes",
  "detectedProblems": [
      {
        "level": "Error",
        "dbObject": "test.partMyisamTable",
         "description": "MyISAM engine does not support native partitioning",
         "dbObjectType": "Table"
      }
  ]
}
```
在這裡，MyISAM 資料表正在使用分割，這需要採取動作才能繼續升級。

**oldTemporalCheck**  
**預先檢查層級：錯誤**  
**舊暫時類型的使用**  
「舊暫時」是指在 MySQL 5.5 版和更低版本中建立的暫時類型資料欄 (例如 `TIMESTAMP` 和 `DATETIME`)。在 MySQL 8.0 中，系統會移除對這些舊暫時資料類型的支援，這表示如果資料庫包含這些舊暫時類型，就無法從 MySQL 5.7 就地升級至 8.0。若要修正此問題，您必須先[重建](https://dev.mysql.com/doc/refman/5.7/en/rebuilding-tables.html)任何包含此類舊暫時日期類型的資料表，才能繼續升級。  
如需 MySQL 5.7 中舊暫時資料類型棄用的詳細資訊，請參閱此[部落格](https://dev.mysql.com/blog-archive/how-to-easily-identify-tables-with-temporal-types-in-old-format/)。如需在 MySQL 8.0 中移除舊暫時資料類型的詳細資訊，請參閱此[部落格](https://dev.mysql.com/blog-archive/mysql-8-0-removing-support-for-old-temporal-datatypes/)。  
在重建資料表空間之前，請參閱 MySQL 文件中的[線上 DDL 操作](https://dev.mysql.com/doc/refman/5.7/en/innodb-online-ddl-operations.html)，以了解鎖定和資料移動對前景交易的影響。
**輸出範例：**  

```
{
  "id": "oldTemporalCheck",
  "title": "Usage of old temporal type",
  "status": "OK",
  "description": "Error: Following table columns use a deprecated and no longer supported temporal disk storage format. They must be converted to the new format before upgrading. It can by done by rebuilding the table using 'ALTER TABLE <table_name> FORCE' command",
  "documentationLink": "https://dev.mysql.com/blog-archive/mysql-8-0-removing-support-for-old-temporal-datatypes/",
  "detectedProblems": [
      {
        "level": "Error",
        "dbObject": "test.55_temporal_table.timestamp_column",
        "description": "timestamp /* 5.5 binary format */",
        "dbObjectType": "Column"
      }
  ]
},
```
會針對資料表 `timestamp_column` 中的資料欄 `test.55_temporal_table` 報告錯誤，因為它使用不再支援的舊暫時磁碟儲存格式。  
若要解決此問題並允許升級繼續進行，請重建資料表，將舊暫時磁碟儲存格式轉換為 MySQL 5.6 中引入的新格式。如需詳細資訊和先決條件，請參閱 MySQL 文件中的[在 3 位元組和 4 位元組 Unicode 字元集之間轉換](https://dev.mysql.com/doc/refman/8.0/en/charset-unicode-conversion.html)。  
執行下列命令來重建此預先檢查中提及的資料表，會將舊暫時類型轉換為較新的格式，精確度為小數秒數。  

```
ALTER TABLE ... ENGINE=InnoDB;
```
如需重建資料表的詳細資訊，請參閱 MySQL 文件中的 [ALTER TABLE 陳述式](https://dev.mysql.com/doc/refman/8.0/en/alter-table.html)。  
在重建有問題的資料表並重新啟動升級之後，相容性檢查會通過，讓升級繼續進行。  

```
{
  "id": "oldTemporalCheck",
  "title": "Usage of old temporal type",
  "status": "OK",
  "detectedProblems": []
}
```

**partitionedTablesInSharedTablespaceCheck**  
**預先檢查層級：錯誤**  
**在共用資料表空間中使用分割資料表**  
從 [MySQL 8.0.13](https://dev.mysql.com/doc/relnotes/mysql/8.0/en/news-8-0-13.html) 開始，已移除在共用資料表空間中放置資料表分割區的支援。升級之前，請將任何此類資料表從共用資料表空間移至 file-per-table 資料表空間。  
在重建資料表空間之前，請參閱 MySQL 文件中的[分割操作](https://dev.mysql.com/doc/refman/5.7/en/innodb-online-ddl-operations.html#online-ddl-partitioning)，以了解鎖定和資料移動對前景交易的影響。
**輸出範例：**  

```
{
  "id": "partitionedTablesInSharedTablespaceCheck",
  "title": "Usage of partitioned tables in shared tablespaces",
  "status": "OK",
  "description": "Error: The following tables have partitions in shared tablespaces. They need to be moved to file-per-table tablespace before upgrading. You can do this by running query like 'ALTER TABLE table_name REORGANIZE PARTITION X INTO (PARTITION X VALUES LESS THAN (30) TABLESPACE=innodb_file_per_table);'",
  "documentationLink": "https://dev.mysql.com/doc/refman/8.0/en/mysql-nutshell.html#mysql-nutshell-removals",
  "detectedProblems": [
      {
        "level": "Error",
        "dbObject": "test.partInnoDBTable",
        "description": "Partition p1 is in shared tablespace innodb",
        "dbObjectType": "Table"
      }
  ]
}
```
預先檢查失敗，因為來自資料表 `test.partInnoDBTable` 的分割區 `p1` 位於系統資料表空間中。  
若要解決此問題，請重建 `test.partInnodbTable` 資料表，將違規分割區放在 file-per-table 資料表空間中的 `p1`。  

```
mysql > ALTER TABLE partInnodbTable REORGANIZE PARTITION p1
    ->   INTO (PARTITION p1 VALUES LESS THAN ('2014-01-01') TABLESPACE=innodb_file_per_table);
Query OK, 0 rows affected, 1 warning (0.02 sec)
Records: 0  Duplicates: 0  Warnings: 0
```
執行此操作後，預先檢查會通過。  

```
{
  "id": "partitionedTablesInSharedTablespaceCheck",
  "title": "Usage of partitioned tables in shared tablespaces",
  "status": "OK",
  "detectedProblems": []
}
```

**removedFunctionsCheck**  
**預先檢查層級：錯誤**  
**使用從最新 MySQL 版本中移除的函數**  
在 MySQL 8.0 中，已移除許多內建函數。此預先檢查會檢查您的資料庫是否有可能使用這些函數的物件。如果找到，則會傳回錯誤。您必須先解決問題，才能重試升級。  
移除的大多數函數都是[空間函數](https://dev.mysql.com/doc/refman/5.7/en/gis-wkt-functions.html)，已被同等 `ST_*` 函數取代。在這些情況下，您可以修改資料庫物件以使用新的程序命名。如需詳細資訊，請參閱 MySQL 文件中的 [Features Removed in MySQL 8.0](https://dev.mysql.com/doc/refman/8.0/en/mysql-nutshell.html#mysql-nutshell-removals) (MySQL 8.0 中移除的功能)。  
**輸出範例：**  

```
{
  "id": "removedFunctionsCheck",
  "title": "Usage of removed functions",
  "status": "OK",
  "description": "Error: The following DB objects use functions that were removed in the latest MySQL version. Please make sure to update them to use supported alternatives before upgrade.",
  "documentationLink": "https://dev.mysql.com/doc/refman/8.0/en/mysql-nutshell.html#mysql-nutshell-removals",
  "detectedProblems": [
      {
        "level": "Error",
        "dbObject": "test.GetLocationsInPolygon",
        "description": "PROCEDURE uses removed function POLYGONFROMTEXT (consider using ST_POLYGONFROMTEXT instead)",
        "dbObjectType": "Routine"
      },
      {
        "level": "Error",
        "dbObject": "test.InsertLocation",
        "description": "PROCEDURE uses removed function POINTFROMTEXT (consider using ST_POINTFROMTEXT instead)",
        "dbObjectType": "Routine"
      }
  ]
},
```
預先檢查會報告 `test.GetLocationsInPolygon` 預存程序正在使用兩個已移除的函數：[POLYGONFROMTEXT](https://dev.mysql.com/doc/refman/5.7/en/gis-wkt-functions.html#function_polyfromtext) 和 [POINTFROMTEXT](https://dev.mysql.com/doc/refman/5.7/en/gis-wkt-functions.html#function_st-mpointfromtext)。它也建議您使用新的 [ST\$1POLYGONFROMTEXT](https://dev.mysql.com/doc/refman/8.0/en/gis-wkt-functions.html#function_st-polyfromtext) 和 [ST\$1POINTFROMTEXT](https://dev.mysql.com/doc/refman/8.0/en/gis-wkt-functions.html#function_st-mpointfromtext) 來取代。使用建議重新建立程序後，預先檢查會成功完成。  

```
{
  "id": "removedFunctionsCheck",
  "title": "Usage of removed functions",
  "status": "OK",
  "detectedProblems": []
},
```
雖然在大多數情況下，已棄用的函數具有直接取代項目，但請務必測試您的應用程式，並檢閱文件以了解因變更而導致的任何行為變更。

**routineSyntaxCheck**  
**預先檢查層級：錯誤**  
**MySQL 語法檢查類似常式的物件**  
MySQL 8.0 引入了一些先前未保留的[預留關鍵字](https://dev.mysql.com/doc/mysqld-version-reference/en/keywords-8-0.html#keywords-new-in-8-0)。升級預先檢查程式會評估資料庫物件名稱及其定義和本文中預留關鍵字的使用情況。如果它偵測到資料庫物件中使用的預留關鍵字，例如預存程序、函數、事件和觸發條件，則升級會失敗，並發佈錯誤至 `upgrade-prechecks.log` 檔案。若要解決此問題，您必須先更新這些物件定義，並在升級之前以單引號 (') 括住任何此類參考。如需在 MySQL 中逸出預留字的詳細資訊，請參閱 MySQL 文件中的[字串常值](https://dev.mysql.com/doc/refman/8.0/en/string-literals.html)。  
或者，您可以將名稱變更為不同的名稱，這可能需要應用程式變更。  
**輸出範例：**  

```
{
  "id": "routineSyntaxCheck",
  "title": "MySQL syntax check for routine-like objects",
  "status": "OK",
  "description": "The following objects did not pass a syntax check with the latest MySQL grammar. A common reason is that they reference names that conflict with new reserved keywords. You must update these routine definitions and `quote` any such references before upgrading.",
  "documentationLink": "https://dev.mysql.com/doc/refman/en/keywords.html",
  "detectedProblems": [
      {
         "level": "Error",
         "dbObject": "test.select_res_word",
         "description": "at line 2,18: unexpected token 'except'",
         "dbObjectType": "Routine"
      }
  ]
}
```
若要修正此問題，請檢查常式定義。  

```
SHOW CREATE PROCEDURE test.select_res_word\G

*************************** 1. row ***************************
           Procedure: select_res_word
            sql_mode: ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
    Create Procedure: CREATE PROCEDURE 'select_res_word'()
BEGIN
    SELECT * FROM except;
END
character_set_client: utf8
collation_connection: utf8_general_ci
  Database Collation: latin1_swedish_ci
1 row in set (0.00 sec)
```
程序使用名為 `except` 的資料表，這是 MySQL 8.0 中的新關鍵字。透過逸出字串常值來重新建立程序。  

```
> drop procedure if exists select_res_word;
Query OK, 0 rows affected (0.00 sec)

> DELIMITER $$
 > CREATE PROCEDURE select_res_word()
    -> BEGIN
    ->     SELECT * FROM 'except';
    -> END$$
Query OK, 0 rows affected (0.00 sec)

 > DELIMITER ;
```
預先檢查現在會通過。  

```
{
  "id": "routineSyntaxCheck",
  "title": "MySQL syntax check for routine-like objects",
  "status": "OK",
  "detectedProblems": []
}
```

**schemaInconsistencyCheck**  
**預先檢查層級：錯誤**  
**因檔案移除或損毀所導致的結構描述不一致**  
如前所述，MySQL 8.0 推出了[單元資料字典](https://dev.mysql.com/doc/refman/8.0/en/data-dictionary-file-removal.html)，該字典會將所有中繼資料存放在 `mysql` 結構描述中的一組內部 InnoDB 資料表中。這種新架構提供交易、[ACID](https://en.wikipedia.org/wiki/ACID) 合規的方式來管理資料庫中繼資料，從舊的檔案型方法解決「單元 DDL」問題。在 MySQL 8.0 之前，如果 DDL 操作意外中斷，結構描述物件可能會變得孤立。在升級期間將檔案型中繼資料遷移至新的單元資料字典資料表，可確保資料庫執行個體中沒有此類孤立結構描述物件。如果遇到任何孤立的物件，升級會失敗。  
為了協助在啟動升級之前偵測這些孤立物件，系統會執行 `schemaInconsistencyCheck` 預先檢查，以確保所有資料字典中繼資料物件都同步。如果偵測到任何孤立的中繼資料物件，則不會繼續升級。若要繼續升級，請清除這些孤立的中繼資料物件。  
如果您在此預先檢查中遇到任何錯誤，請向 [AWS Support](https://aws.amazon.com/support) 開立案例，以請求解決中繼資料不一致的問題。或者，您可以執行邏輯傾印，然後還原至新的 Aurora MySQL 第 3 版資料庫叢集，以重試升級。  
**輸出範例：**  

```
{
  "id": "schemaInconsistencyCheck",
  "title": "Schema inconsistencies resulting from file removal or corruption",
  "status": "OK",
  "description": "Error: Following tables show signs that either table datadir directory or frm file was removed/corrupted. Please check server logs, examine datadir to detect the issue and fix it before upgrade",
  "detectedProblems": [
      {
        "level": "Error",
        "dbObject": "test.schemaInconsistencyCheck_failure",
        "description": "present in INFORMATION_SCHEMA's INNODB_SYS_TABLES table but missing from TABLES table"
      }
  ]
}
```
預先檢查會報告 `test.schemaInconsistencyCheck_failure` 資料表的中繼資料不一致。在此情況下，資料表存在於 InnoDB 儲存引擎中繼資料 (`information_schema.INNODB_SYS_TABLES`) 中，但不存在於 MySQL 中繼資料 (`information_schema.TABLES`) 中。

### Aurora MySQL 會預先檢查報告錯誤
<a name="precheck-descriptions-errors.aurora"></a>

下列預先檢查專屬於 Aurora MySQL：
+ [auroraCheckDDLRecovery](#auroraCheckDDLRecovery)
+ [auroraCheckRdsUpgradePrechecksTable](#auroraCheckRdsUpgradePrechecksTable)
+ [auroraFODUpgradeCheck](#auroraFODUpgradeCheck)
+ [auroraGetDanglingFulltextIndex](#auroraGetDanglingFulltextIndex)
+ [auroraUpgradeCheckForDatafilePathInconsistency](#auroraUpgradeCheckForDatafilePathInconsistency)
+ [auroraUpgradeCheckForFtsSpaceIdZero](#auroraUpgradeCheckForFtsSpaceIdZero)
+ [auroraUpgradeCheckForIncompleteXATransactions](#auroraUpgradeCheckForIncompleteXATransactions)
+ [auroraUpgradeCheckForInstanceLimit](#auroraUpgradeCheckForInstanceLimit)
+ [auroraUpgradeCheckForInternalUsers](#auroraUpgradeCheckForInternalUsers)
+ [auroraUpgradeCheckForInvalidUtf8mb3CharacterStringInViews](#auroraUpgradeCheckForInvalidUtf8mb3CharacterStringInViews)
+ [auroraUpgradeCheckForInvalidUtf8mb3ColumnComments](#auroraUpgradeCheckForInvalidUtf8mb3ColumnComments)
+ [auroraUpgradeCheckForInvalidUtf8mb3IndexComments](#auroraUpgradeCheckForInvalidUtf8mb3IndexComments)
+ [auroraUpgradeCheckForInvalidUtf8mb3TableComments](#auroraUpgradeCheckForInvalidUtf8mb3TableComments)
+ [auroraUpgradeCheckForMasterUser](#auroraUpgradeCheckForMasterUser)
+ [auroraUpgradeCheckForPrefixIndexOnGeometryColumns](#auroraUpgradeCheckForPrefixIndexOnGeometryColumns)
+ [auroraUpgradeCheckForSpecialCharactersInProcedures](#auroraUpgradeCheckForSpecialCharactersInProcedures)
+ [auroraUpgradeCheckForSysSchemaObjectTypeMismatch](#auroraUpgradeCheckForSysSchemaObjectTypeMismatch)
+ [auroraUpgradeCheckForViewColumnNameLength](#auroraUpgradeCheckForViewColumnNameLength)
+ [auroraUpgradeCheckIndexLengthLimitOnTinyColumns](#auroraUpgradeCheckIndexLengthLimitOnTinyColumns)
+ [auroraUpgradeCheckMissingInnodbMetadataForMysqlHostTable](#auroraUpgradeCheckMissingInnodbMetadataForMysqlHostTable)

**auroraCheckDDLRecovery**  
**預先檢查層級：錯誤**  
**檢查與 Aurora DDL 復原功能相關的成品**  
作為 Aurora MySQL 中資料定義語言 (DDL) 復原實作的一部分，傳輸中 DDL 陳述式的中繼資料會保留在 `ddl_log_table` 結構描述中的 `ddl_log_md_table` 和 `mysql` 資料表中。第 3 版以後不支援 Aurora 的 DDL 復原實作，因為此功能是 MySQL 8.0 中新[單元資料字典](https://dev.mysql.com/doc/refman/8.0/en/data-dictionary-file-removal.html)實作的一部分。如果您在相容性檢查期間執行任何 DDL 陳述式，此預先檢查可能會失敗。我們建議您在沒有 DDL 陳述式執行時嘗試升級。  
如果此預先檢查失敗，而沒有任何執行中的 DDL 陳述式，請向 [AWS Support](https://aws.amazon.com/support) 開立案例，以請求解決中繼資料不一致的問題。或者，您可以執行邏輯傾印，然後還原至新的 Aurora MySQL 第 3 版資料庫叢集，以重試升級。  
如果有任何 DDL 陳述式正在執行，預先檢查輸出會列印下列訊息：  

```
“There are DDL statements in process. Please allow DDL statements to finish before upgrading.”
```
**輸出範例：**  

```
{
  "id": "auroraCheckDDLRecovery",
  "title": "Check for artifacts related to Aurora DDL recovery feature",
  "status": "OK",
  "description": "Aurora implementation of DDL recovery is not supported from 3.x onwards. This check verifies that the database do not have artifacts realted to the feature",
  "detectedProblems": [
      {
        "level": "Error",
        "dbObject": "mysql.ddl_log_md_table",
        "description": "Table mysql.ddl_log_md_table is not empty. Your database has pending DDL recovery operations. Reachout to AWS support for assistance."
      },
      {
        "level": "Error",
        "dbObject": "mysql.ddl_log_table",
        "description": "Table mysql.ddl_log_table is not empty. Your database has pending DDL recovery operations. Reachout to AWS support for assistance."
      },
      {
        "level": "Error",
        "dbObject": "information_schema.processlist",
        "description": "There are DDL statements in process. Please allow DDL statements to finish before upgrading."
      }
  ]
}
```
由於與相容性檢查同時執行的傳輸中 DDL，預先檢查傳回錯誤。我們建議您在未執行任何 DDL 的情況下重試升級。

**auroraCheckRdsUpgradePrechecksTable**  
**預先檢查層級：錯誤**  
**檢查 `mysql.rds_upgrade_prechecks` 資料表是否存在**  
這是 RDS 服務執行的僅限內部預先檢查。升級時會自動處理任何錯誤，並且可以安全地忽略。  
如果您在此預先檢查中遇到任何錯誤，請向 [AWS Support](https://aws.amazon.com/support) 開立案例，以請求解決中繼資料不一致的問題。或者，您可以執行邏輯傾印，然後還原至新的 Aurora MySQL 第 3 版資料庫叢集，以重試升級。  

```
{
  "id": "auroraCheckRdsUpgradePrechecksTable",
  "title": "Check existence of mysql.rds_upgrade_prechecks table",
  "status": "OK",
  "detectedProblems": []
}
```

**auroraFODUpgradeCheck**  
**預先檢查層級：錯誤**  
**檢查與 Aurora 快速 DDL 功能相關的成品**  
[快速 DDL](AuroraMySQL.Managing.FastDDL.md) 最佳化是在 Aurora MySQL 第 2 版的[實驗室模式中](AuroraMySQL.Updates.LabMode.md)推出，以提高某些 DDL 操作的效率。在 Aurora MySQL 第 3 版中，實驗室模式已移除，快速 DDL 實作已由名為[即時 DDL](https://dev.mysql.com/doc/refman/8.4/en/innodb-online-ddl-operations.html) 的 MySQL 8.0 功能取代。  
在升級至 Aurora MySQL 第 3 版之前，任何在實驗室模式中使用快速 DDL 的資料表都必須執行 `OPTIMIZE TABLE` 或 `ALTER TABLE ... ENGINE=InnoDB` 命令來重建，以確保與 Aurora MySQL 第 3 版的相容性。  
此預先檢查會傳回任何此類資料表的清單。重建傳回的資料表之後，您可以重試升級。  
**輸出範例：**  

```
{
  "id": "auroraFODUpgradeCheck",
  "title": "Check for artifacts related to Aurora fast DDL feature",
  "status": "OK",
  "description": "Aurora fast DDL is not supported from 3.x onwards. This check verifies that the database does not have artifacts related to the feature",
  "documentationLink": "https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/AuroraMySQL.Managing.FastDDL.html#AuroraMySQL.Managing.FastDDL-v2",
  "detectedProblems": [
      {
        "level": "Error",
        "dbObject": "test.test",
        "description": "Your table has pending Aurora fast DDL operations. Run 'OPTIMIZE TABLE <table name>' for the table to apply all the pending DDL updates. Then try the upgrade again."
      }
  ]
}
```
預先檢查會報告資料表 `test.test` 有待定的快速 DDL 操作。  
若要允許繼續升級，您可以重建資料表，然後重試升級。  
在重建資料表空間之前，請參閱 MySQL 文件中的[線上 DDL 操作](https://dev.mysql.com/doc/refman/5.7/en/innodb-online-ddl-operations.html)，以了解鎖定和資料移動對前景交易的影響。

```
mysql> optimize table test.test;
+-----------+----------+----------+-------------------------------------------------------------------+
| Table     | Op       | Msg_type | Msg_text                                                          |
+-----------+----------+----------+-------------------------------------------------------------------+
| test.test | optimize | note     | Table does not support optimize, doing recreate + analyze instead |
| test.test | optimize | status   | OK                                                                |
+-----------+----------+----------+-------------------------------------------------------------------+
2 rows in set (0.04 sec)
```
重建資料表後，預先檢查會成功。  

```
{
  "id": "auroraFODUpgradeCheck",
  "title": "Check for artifacts related to Aurora fast DDL feature",
  "status": "OK",
  "detectedProblems": []
}
```

**auroraGetDanglingFulltextIndex**  
**預先檢查層級：錯誤**  
**具有懸置 `FULLTEXT` 索引參考的資料表**  
在 MySQL 5.6.26 之前，捨棄全文搜尋索引後，隱藏的 `FTS_DOC_ID` 和 `FTS_DOC_ID_INDEX` 資料欄可能會變得孤立。如需詳細資訊，請參閱[錯誤 \$176012](https://bugs.mysql.com/bug.php?id=76012)。  
如果您在發生這種情況的舊版 MySQL 上建立任何資料表，可能會導致升級至 Aurora MySQL 第 3 版失敗。此預先檢查會確認資料庫叢集上沒有此類孤立或「懸置」的全文索引，然後再升級至 MySQL 8.0。如果此預先檢查失敗，請重建包含此類懸置全文索引的任何資料表。  
**輸出範例：**  

```
{
  "id": "auroraGetDanglingFulltextIndex",
  "title": "Tables with dangling FULLTEXT index reference",
  "status": "OK",
  "description": "Error: The following tables contain dangling FULLTEXT index which is not supported. It is recommended to rebuild the table before upgrade.",
  "detectedProblems": [
      {
        "level": "Error",
        "dbObject": "test.table_with_fts_index",
        "description": "Table `test.table_with_fts_index` contains dangling FULLTEXT index. Kindly recreate the table before upgrade."
      }
  ]
},
```
預先檢查會報告 `test.table_with_fts_index` 資料表的錯誤，因為它包含懸置的全文索引。若要允許繼續升級，請重建資料表以清除全文索引輔助資料表。使用 `OPTIMIZE TABLE test.table_with_fts_index` 或 `ALTER TABLE test.table_with_fts_index, ENGINE=INNODB`。  
重建資料表後，預先檢查會通過。  

```
{
  "id": "auroraGetDanglingFulltextIndex",
  "title": "Tables with dangling FULLTEXT index reference",
  "status": "OK",
  "detectedProblems": []
},
```

**auroraUpgradeCheckForDatafilePathInconsistency**  
**預先檢查層級：錯誤**  
**檢查與 `ibd` 檔案路徑相關的不一致**  
此預先檢查僅適用於 Aurora MySQL 3.03.0 版及更低版本。如果此預先檢查發生錯誤，請升級至 Aurora MySQL 3.04 版或更新版本。  
**輸出範例：**  

```
{
  "id": "auroraUpgradeCheckForDatafilePathInconsistency",
  "title": "Check for inconsistency related to ibd file path.",
  "status": "OK",
  "detectedProblems": []
}
```

**auroraUpgradeCheckForFtsSpaceIdZero**  
**預先檢查層級：錯誤**  
**檢查空間 ID 為零的全文索引**  
在 MySQL 中，當您將[全文索引](https://dev.mysql.com/doc/refman/5.7/en/innodb-fulltext-index.html)新增至 InnoDB 資料表時，會建立多個輔助索引資料表空間。由於舊版 MySQL 在 5.6.20 版中修正的[錯誤](https://bugs.mysql.com/bug.php?id=72132)，這些輔助索引資料表可能在[系統資料表空間](https://dev.mysql.com/doc/refman/5.7/en/glossary.html#glos_system_tablespace)中建立，而不是在自己的 InnoDB 資料表空間中建立。  
如果有任何此類輔助資料表空間存在，升級將會失敗。重新建立預先檢查錯誤中提及的全文索引，然後重試升級。  
**輸出範例：**  

```
{
  "id": "auroraUpgradeCheckForFtsSpaceIdZero",
  "title": "Check for fulltext index with space id as zero",
  "status": "OK",
  "description": "The auxiliary tables of FTS indexes on the table are created in system table-space. Due to this DDL queries executed on MySQL8.0 shall cause database unavailability. To avoid that, drop and recreate all the FTS indexes on the table or rebuild the table using ALTER TABLE query before the upgrade.",
  "detectedProblems": [
      {
        "level": "Error",
        "dbObject": "test.fts_space_zero_check",
        "description": " The auxiliary tables of FTS indexes on the table 'test.fts_space_zero_check' are created in system table-space due to https://bugs.mysql.com/bug.php?id=72132. In MySQL8.0, DDL queries executed on this table shall cause database unavailability. To avoid that, drop and recreate all the FTS indexes on the table or rebuild the table using ALTER TABLE query before the upgrade."
      }
  ]
},
```
預先檢查會報告 `test.fts_space_zero_check` 資料表的錯誤，因為它在系統資料表空間中有輔助全文搜尋 (FTS) 資料表。  
在您捨棄並重新建立與此資料表相關聯的 FTS 索引後，預先檢查會成功。  
在重建資料表空間之前，請參閱 MySQL 文件中的[分割操作](https://dev.mysql.com/doc/refman/5.7/en/innodb-online-ddl-operations.html#online-ddl-partitioning)，以了解鎖定和資料移動對前景交易的影響。

```
{
 "id": "auroraUpgradeCheckForFtsSpaceIdZero",
 "title": "Check for fulltext index with space id as zero",
 "status": "OK",
 "detectedProblems": []
}
```

**auroraUpgradeCheckForIncompleteXATransactions**  
**預先檢查層級：錯誤**  
**檢查 XA 交易是否處於預備狀態**  
執行主要版本升級程序時，Aurora MySQL 第 2 版資料庫執行個體必須進行[正常關閉](https://dev.mysql.com/doc/refman/5.7/en/glossary.html#glos_slow_shutdown)。這可確保所有交易都已遞交或復原，而且 InnoDB 已清除所有復原日誌記錄。由於交易復原是必要的，如果您的資料庫有任何 [XA 交易](https://dev.mysql.com/doc/refman/5.7/en/xa.html)處於預備狀態，它可能會封鎖正常關閉，使其無法繼續。因此，如果偵測到任何預備 XA 交易，在您採取動作遞交或復原之前，升級將無法繼續。  
如需使用 `XA RECOVER` 尋找處於預備狀態的 XA 交易的詳細資訊，請參閱 MySQL 文件中的 [XA 交易 SQL 陳述式](https://dev.mysql.com/doc/refman/5.7/en/xa-statements.html)。如需 XA 交易狀態的詳細資訊，請參閱 MySQL 文件中的 [XA 交易狀態](https://dev.mysql.com/doc/refman/5.7/en/xa-states.html)。  
**輸出範例：**  

```
{
  "id": "auroraUpgradeCheckForIncompleteXATransactions",
  "title": "Pre-checks for XA Transactions in prepared state.",
  "status": "OK",
  "description": "Your cluster currently has XA transactions in the prepared state. To proceed with the upgrade, commit or rollback these transactions.",
  "detectedProblems": [
      {
        "level": "Error",
        "dbObject": "all",
        "description": "Your cluster currently has XA transactions in the prepared state. To proceed with the upgrade, commit or rollback these transactions."
      }
  ]
}
```
此預先檢查會報告錯誤，因為有交易處於預備狀態，應遞交或復原。  
登入資料庫後，您可以檢查 [information\$1schema.innodb\$1trx](https://dev.mysql.com/doc/refman/5.7/en/information-schema-innodb-trx-table.html) 資料表和 `XA RECOVER` 輸出以取得詳細資訊。  
在遞交或復原交易之前，我們建議您檢閱 [MySQL 文件](https://dev.mysql.com/doc/refman/5.7/en/xa-restrictions.html)和應用程式需求。

```
mysql> select trx_started,
    trx_mysql_thread_id,
    trx_id,trx_state,
    trx_operation_state,
    trx_rows_modified,
    trx_rows_locked 
from 
    information_schema.innodb_trx;
+---------------------+---------------------+---------+-----------+---------------------+-------------------+-----------------+
| trx_started         | trx_mysql_thread_id | trx_id  | trx_state | trx_operation_state | trx_rows_modified | trx_rows_locked |
+---------------------+---------------------+---------+-----------+---------------------+-------------------+-----------------+
| 2024-08-12 01:09:39 |                   0 | 2849470 | RUNNING   | NULL                |                 1 |               0 |
+---------------------+---------------------+---------+-----------+---------------------+-------------------+-----------------+
1 row in set (0.00 sec)

mysql> xa recover;
+----------+--------------+--------------+--------+
| formatID | gtrid_length | bqual_length | data   |
+----------+--------------+--------------+--------+
|        1 |            6 |            0 | xatest |
+----------+--------------+--------------+--------+
1 row in set (0.00 sec)
```
在這種情況下，我們會復原預備交易。  

```
mysql> XA ROLLBACK 'xatest';
Query OK, 0 rows affected (0.00 sec)
v
mysql> xa recover;
Empty set (0.00 sec)
```
在復原 XA 交易之後，預先檢查會成功。  

```
{
  "id": "auroraUpgradeCheckForIncompleteXATransactions",
  "title": "Pre-checks for XA Transactions in prepared state.",
  "status": "OK",
  "detectedProblems": []
}
```

**auroraUpgradeCheckForInstanceLimit**  
**預先檢查層級：錯誤**  
**檢查目前執行個體類別是否支援升級**  
目前不支援從寫入器[資料庫執行個體類別](Concepts.DBInstanceClass.md)為 db.r6i.32xlarge 的 Aurora MySQL 2.12.0 或 2.12.1 版執行就地升級。在這種情況下，預先檢查會傳回錯誤。若要允許繼續升級，您可以將資料庫執行個體類別變更為 db.r6i.24xlarge 或更小。或者，您可以升級至 Aurora MySQL 2.12.2 版或更新版本，其中 db.r6i.32xlarge 支援就地升級至 Aurora MySQL 第 3 版。  
**輸出範例：**  

```
{
  "id": "auroraUpgradeCheckForInstanceLimit",
  "title": "Checks if upgrade is supported on the current instance class",
  "status": "OK",
  "description": "Upgrade from Aurora Version 2.12.0 and 2.12.1 may fail for 32.xl and above instance class.",
  "detectedProblems": [
      {
        "level": "Error",
        "dbObject": "all",
        "description": "Upgrade is not supported on this instance size for Aurora MySql Version 2.12.1. Before upgrading to Aurora MySql 3, please consider either: 1. Changing the instance class to 24.xl or lower. -or- 2. Upgrading to patch version 2.12.2 or higher."
      }
  ]
},
```
預先檢查會傳回錯誤，因為寫入器資料庫執行個體正在使用 db.r6i.32xlarge 執行個體類別，且正在 Aurora MySQL 2.12.1 版上執行。

**auroraUpgradeCheckForInternalUsers**  
**預先檢查層級：錯誤**  
**檢查 8.0 內部使用者**  
此預先檢查僅適用於 Aurora MySQL 3.03.0 版及更低版本。如果此預先檢查發生錯誤，請升級至 Aurora MySQL 3.04 版或更新版本。  
**輸出範例：**  

```
{
  "id": "auroraUpgradeCheckForInternalUsers",
  "title": "Check for 8.0 internal users.",
  "status": "OK",
  "detectedProblems": []
}
```

**auroraUpgradeCheckForInvalidUtf8mb3CharacterStringInViews**  
**預先檢查層級：錯誤**  
**檢查檢視定義中是否有無效的 utf8mb3 字元**  
此預先檢查可識別包含無效 `utf8mb3` 字元編碼註解的檢視。在 MySQL 8.0 中，更嚴格的驗證會套用至中繼資料中的字元編碼，包括檢視註解。如果任何檢視定義包含 `utf8mb3` 字元集中無效的字元，升級會失敗。  
若要解決此問題，請修改檢視定義以移除或取代任何非 BMP 字元，然後再嘗試升級。  
**輸出範例：**  

```
{
"id": "auroraUpgradeCheckForInvalidUtf8mb3CharacterStringInViews",
"title": "Check for invalid utf8mb3 character string.",
"status": "OK",
"description": "Definition of following view(s) has/have invalid utf8mb3 character string.",
"detectedProblems": [
        {
            "level": "Error",
            "dbObject": "precheck.utf8mb3_invalid_char_view",
            "description": "Definition of view precheck.utf8mb3_invalid_char_view contains an invalid utf8mb3 character string. This is due to https://bugs.mysql.com/bug.php?id=110177. To fix the inconsistency, we recommend you to modify the view definition to not use non-BMP characters and try the upgrade again."
        }
    ]
},
```
預先檢查會報告 `utf8mb3_invalid_char_view` 檢視定義在其定義中包含無效的 `utf8mb3` 字元。  
若要解決此問題，請識別包含不支援字元的檢視，並更新註解。首先，檢查檢視結構並識別註解。  

```
MySQL> SHOW CREATE VIEW precheck.utf8mb3_invalid_char_view\G
*************************** 1. row ***************************
                View: utf8mb3_invalid_char_view
        Create View: CREATE ALGORITHM=UNDEFINED DEFINER=`admin`@`%` SQL SECURITY DEFINER VIEW `utf8mb3_invalid_char_view` AS select 'This row contains a dolphin 🐬' AS `message`
character_set_client: utf8
collation_connection: utf8_general_ci
1 row in set, 1 warning (0.00 sec)
```
識別包含錯誤的檢視後，請將檢視取代為 `CREATE OR REPLACE VIEW` 陳述式。  

```
MySQL> CREATE OR REPLACE VIEW precheck.utf8mb3_invalid_char_view AS select 'This view definition to not use non-BMP characters' AS message;
```
更新包含不支援字元的所有檢視定義後，預先檢查會通過，且升級可以繼續進行。  

```
{
"id": "auroraUpgradeCheckForInvalidUtf8mb3ColumnComments",
"title": "Check for invalid utf8mb3 column comments.",
"status": "OK",
"detectedProblems": []
}
```

**auroraUpgradeCheckForInvalidUtf8mb3ColumnComments**  
**預先檢查層級：錯誤**  
**檢查 utf8mb3 資料欄註解是否無效**  
此預先檢查會識別包含含有無效 `utf8mb3` 字元編碼之資料欄註解的資料表。在 MySQL 8.0 中，更嚴格的驗證會套用至中繼資料中的字元編碼，包括資料欄註解。如果任何資料欄註解包含 utf8mb3 字元集中無效的字元，升級將會失敗。  
若要解決此問題，您必須在嘗試升級之前修改資料欄註解，以移除或取代任何非 BMP 字元。您可以使用 `ALTER TABLE` 陳述式來更新資料欄註解。  
**輸出範例：**  

```
{
  "id": "auroraUpgradeCheckForInvalidUtf8mb3ColumnComments",
  "title": "Check for invalid utf8mb3 column comments.",
  "status": "OK",
  "description": "Following table(s) has/have invalid utf8mb3 comments on the column/columns.",
  "detectedProblems": [
      {
        "level": "Error",
        "dbObject": "test.t2",
        "description": "Table test.t2 has invalid utf8mb3 comments in it's column/columns. This is due to non-BMP characters in the comment field. To fix the inconsistency, we recommend you to modify comment fields to not use non-BMP characters and try the upgrade again."
      }
  ]
}
```
預先檢查會報告 `test.t2` 資料表在一或多個資料欄註解中包含無效的 `utf8mb3` 字元，特別是因為存在非 BMP 字元。  
若要解決此問題，您可以識別有問題的資料欄並更新其註解。首先，檢查資料表結構以識別具有註解的資料欄：  

```
mysql> SHOW CREATE TABLE test.t2\G
```
使用有問題的註解識別資料欄後，請使用 `ALTER TABLE` 陳述式更新資料欄。例如：  

```
mysql> ALTER TABLE test.t2 MODIFY COLUMN column_name data_type COMMENT 'Updated comment without non-BMP characters';
```
或者，您可以完全移除註解：  

```
mysql> ALTER TABLE test.t2 MODIFY COLUMN column_name data_type COMMENT '';
```
更新所有有問題的資料欄註解後，預先檢查將會通過，而且升級可以繼續：  

```
{
  "id": "auroraUpgradeCheckForInvalidUtf8mb3ColumnComments",
  "title": "Check for invalid utf8mb3 column comments.",
  "status": "OK",
  "detectedProblems": []
}
```
修改資料欄註解之前，請確定任何依賴這些註解的應用程式程式碼或文件都會隨之更新。如果您的應用程式需要非 BMP 字元，請考慮遷移至 utf8mb4 字元集，以獲得更好的 Unicode 支援。

**auroraUpgradeCheckForInvalidUtf8mb3IndexComments**  
**預先檢查層級：錯誤**  
**檢查 utf8mb3 索引註解是否無效**  
此預先檢查會識別包含索引註解且 `utf8mb3` 字元編碼無效之資料表。在 MySQL 8.0 中，更嚴格的驗證會套用至中繼資料中的字元編碼，包括索引註解。如果任何索引註解包含字元集中無效的 `utf8mb3` 字元，升級會失敗。  
若要解決此問題，您必須在嘗試升級之前修改索引註解，以移除或取代任何非 BMP 字元。  
**輸出範例：**  

```
{
    "id": "auroraUpgradeCheckForInvalidUtf8mb3IndexComments",
    "title": "Check for invalid utf8mb3 index comments.",
    "status": "OK",
    "description": "Following table(s) has/have invalid utf8mb3 comments on the index.",
    "detectedProblems": [
        {
            "level": "Error",
            "dbObject": "precheck.utf8mb3_tab_index_comment",
            "description": "Table precheck.utf8mb3_tab_index_comment has invalid utf8mb3 comments in it's index. This is due to https://bugs.mysql.com/bug.php?id=110177. To fix the inconsistency, we recommend you to modify comment fields to not use non-BMP characters and try the upgrade again."
        }
    ]
},
```
預先檢查會報告 `utf8mb3_tab_index_comment` 資料表在一或多個資料欄註解中包含無效的 `utf8mb3` 字元，特別是因為存在非 BMP 字元。  
若要解決此問題，請先檢查資料表結構，以識別包含有問題註解的索引。  

```
MySQL> SHOW CREATE TABLE precheck.utf8mb3_tab_index_comment\G
*************************** 1. row ***************************
    Table: utf8mb3_tab_index_comment
Create Table: CREATE TABLE `utf8mb3_tab_index_comment` (
`id` int(11) DEFAULT NULL,
`name` varchar(100) DEFAULT NULL,
KEY `idx_name` (`name`) COMMENT 'Name index 🐬'
) ENGINE=InnoDB DEFAULT CHARSET=utf8
1 row in set (0.01 sec)
```
識別包含使用不支援字元之註解的索引後，請捨棄並重新建立索引。  
捨棄和重新建立資料表索引可能會導致停機時間。建議您在維護期間規劃並排程此操作。

```
MySQL> ALTER TABLE precheck.utf8mb3_tab_index_comment DROP INDEX idx_name;
MySQL> ALTER TABLE precheck.utf8mb3_tab_index_comment ADD INDEX idx_name(name);
```
下列範例顯示重新建立索引的另一種方式。  

```
MySQL> ALTER TABLE utf8mb3_tab_index_comment DROP INDEX idx_name, ADD INDEX idx_name (name) COMMENT 'Updated comment without non-BMP characters';
```
在您移除或更新所有不支援的索引註解後，預先檢查會通過，且升級可以繼續進行。  

```
{
"id": "auroraUpgradeCheckForInvalidUtf8mb3IndexComments",
"title": "Check for invalid utf8mb3 index comments.",
"status": "OK",
"detectedProblems": []
},
```

**auroraUpgradeCheckForInvalidUtf8mb3TableComments**  
**預先檢查層級：錯誤**  
**檢查資料表定義中是否有無效的 utf8mb3 字元**  
此預先檢查可識別包含無效 `utf8mb3` 字元編碼註解的資料表。在 MySQL 8.0 中，更嚴格的驗證會套用至中繼資料中的字元編碼，包括資料表註解。如果任何資料表註解包含字元集中無效的 `utf8mb3` 字元，升級會失敗。  
若要解決此問題，您必須在嘗試升級之前修改資料表註解，以移除或取代任何非 BMP 字元。  
**輸出範例：**  

```
{
    "id": "auroraUpgradeCheckForInvalidUtf8mb3TableComments",
    "title": "Check for invalid utf8mb3 table comments.",
    "status": "OK",
    "description": "Following table(s) has/have invalid utf8mb3 comments.",
    "detectedProblems": [
        {
            "level": "Error",
            "dbObject": "precheck.utf8mb3_table_with_comment",
            "description": "Table precheck.utf8mb3_table_with_comment has invalid utf8mb3 comments. This is due to https://bugs.mysql.com/bug.php?id=110177. To fix the inconsistency, we recommend you to modify comment fields to not use non-BMP characters and try the upgrade again."
        }
        
    ]
},
```
預先檢查會報告測試資料庫中 `utf8mb3_table_with_comment` 資料表定義的無效 `utf8mb3` 註解。  
若要解決此問題，請識別包含不支援字元的資料表，並更新註解。首先，檢查資料表結構並識別註解。  

```
MySQL> SHOW CREATE TABLE precheck.utf8mb3_table_with_comment\G
*************************** 1. row ***************************
    Table: utf8mb3_table_with_comment
Create Table: CREATE TABLE `utf8mb3_table_with_comment` (
`id` int(11) NOT NULL,
`name` varchar(100) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COMMENT='This table comment contains flag 🏳️'
1 row in set (0.00 sec)
```
識別包含不支援聊天程式的資料表註解後，請使用 `ALTER TABLE` 陳述式更新註解。  

```
MySQL> ALTER TABLE precheck.utf8mb3_table_with_comment COMMENT='Updated comment without non-BMP characters';
```
或者，您可以移除該註解。  

```
MySQL> ALTER TABLE precheck.utf8mb3_table_with_comment COMMENT='';
```
從所有資料表註解中移除所有不支援的字元後，預先檢查會成功。  

```
{
"id": "auroraUpgradeCheckForInvalidUtf8mb3TableComments",
"title": "Check for invalid utf8mb3 table comments.",
"status": "OK",
"detectedProblems": []
},
```

**auroraUpgradeCheckForMasterUser**  
**預先檢查層級：錯誤**  
**檢查 RDS 主要使用者是否存在**  
MySQL 8 已新增支援[角色](https://dev.mysql.com/doc/refman/8.0/en/roles.html)和[動態權限](https://dev.mysql.com/doc/refman/8.0/en/privileges-provided.html#static-dynamic-privileges)的新權限模型，讓權限管理更容易且更精細。作為此變更的一部分，Aurora MySQL 推出了新的 `rds_superuser_role`，在從 Aurora MySQL 第 2 版升級至第 3 版時，會自動授予資料庫的主要使用者。  
如需 Aurora MySQL 中指派給主要使用者的角色和權限的詳細資訊，請參閱 [主要使用者帳戶權限](UsingWithRDS.MasterAccounts.md)。如需 Aurora MySQL 第 3 版中角色型權限模型的詳細資訊，請參閱 [角色型權限模型](AuroraMySQL.Compare-80-v3.md#AuroraMySQL.privilege-model)。  
此預先檢查會確認主要使用者是否存在於資料庫中。如果主要使用者不存在，預先檢查會失敗。若要允許繼續升級，請重設主要使用者密碼或手動建立使用者，以重新建立主要使用者。然後重試升級。如需重設主要使用者密碼的詳細資訊，請參閱 [變更資料庫主要使用者的密碼](Aurora.Modifying.md#Aurora.Modifying.Password)。  
**輸出範例：**  

```
{
  "id": "auroraUpgradeCheckForMasterUser",
  "title": "Check if master user exists",
  "status": "OK",
  "description": "Throws error if master user has been dropped!",
  "documentationLink": "https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/UsingWithRDS.MasterAccounts.html",
  "detectedProblems": [
      {
        "level": "Error",
        "dbObject": "all",
        "description": "Your Master User on host '%' has been dropped. To proceed with the upgrade, recreate the master user `reinvent` on default host '%'"
      }
  ]
}
```
重設主要使用者密碼後，預先檢查將會通過，而且您可以重試升級。  
下列範例使用 AWS CLI 重設密碼。密碼變更會立即套用。  

```
aws rds modify-db-cluster \
    --db-cluster-identifier my-db-cluster \
    --master-user-password my-new-password
```
然後，預先檢查成功。  

```
{
  "id": "auroraUpgradeCheckForMasterUser",
  title": "Check if master user exists",
  "status": "OK",
  "detectedProblems": []
}
```

**auroraUpgradeCheckForPrefixIndexOnGeometryColumns**  
**預先檢查層級：錯誤**  
**檢查字首索引上的幾何資料欄**  
從 [MySQL 8.0.12](https://dev.mysql.com/doc/relnotes/mysql/8.0/en/news-8-0-12.html#mysqld-8-0-12-spatial-support) 開始，您無法再使用[幾何](https://dev.mysql.com/doc/refman/5.7/en/gis-data-formats.html)資料類型在資料欄上建立[字首](https://dev.mysql.com/doc/refman/5.7/en/column-indexes.html#column-indexes-prefix)索引。如需詳細資訊，請參閱 [WL\$111808](https://dev.mysql.com/worklog/task/?id=11808)。  
如果有任何此類索引存在，您的升級將會失敗。若要解決此問題，請在預先檢查失敗時提及的資料表上捨棄字首 `GEOMETRY` 索引。  
**輸出範例：**  

```
{
  "id": "auroraUpgradeCheckForPrefixIndexOnGeometryColumns",
  "title": "Check for geometry columns on prefix indexs",
  "status": "OK",
  "description": "Consider dropping the prefix Indexes of geometry columns and restart the upgrade.",
  "detectedProblems": [
      {
        "level": "Error",
        "dbObject": "test.geom_index_prefix",
        "description": "Table `test`.`geom_index_prefix` has an index `LatLon` on geometry column/s. Mysql 8.0 does not support this type of index on a geometry column https://dev.mysql.com/worklog/task/?id=11808. To upgrade to MySQL 8.0, Run 'DROP INDEX `LatLon` ON `test`.`geom_index_prefix`;"
      }
  ]
}
```
預先檢查會報告錯誤，因為 `test.geom_index_prefix` 資料表包含 `GEOMETRY` 欄上有字首的索引。  
捨棄此索引後，預先檢查會成功。  

```
{
  "id": "auroraUpgradeCheckForPrefixIndexOnGeometryColumns",
  "title": "Check for geometry columns on prefix indexs",
  "status": "OK",
  "detectedProblems": []
}
```

**auroraUpgradeCheckForSpecialCharactersInProcedures**  
**預先檢查層級：錯誤**  
**檢查預存程序中與特殊字元相關的不一致**  
在 MySQL 8.0 之前，資料庫名稱、資料表名稱和其他物件會對應至資料目錄中的檔案，也就是檔案型中繼資料。在升級至 MySQL 8.0 的過程中，所有資料庫物件都會遷移至存放在 `mysql` 結構描述中的新內部資料字典資料表，以支援新實作的[單元資料字典](https://dev.mysql.com/doc/refman/8.0/en/data-dictionary-file-removal.html)。在遷移預存程序的過程中，系統會驗證每個程序的程序定義和本文，因為它會擷取到新的資料字典中。  
在 MySQL 8 之前，在某些情況下，可以建立預存常式，或直接插入 `mysql.proc` 資料表中包含特殊字元的程序。例如，您可以建立預存程序，其中包含不合規、[非中斷空格字元](https://en.wikipedia.org/wiki/Non-breaking_space) `\xa0` 的註解。如果遇到任何此類程序，升級會失敗。  
此預先檢查會驗證預存程序的本文和定義不包含任何此類字元。若要允許繼續升級，請重新建立這些預存程序，而不含任何隱藏或特殊字元。  
**輸出範例：**  

```
{
  "id": "auroraUpgradeCheckForSpecialCharactersInProcedures",
  "title": "Check for inconsistency related to special characters in stored procedures.",
  "status": "OK",
  "description": "Following procedure(s) has special characters inconsistency.",
  "detectedProblems": [
      {
        "level": "Error",
        "dbObject": "information_schema.routines",
        "description": "Data Dictionary Metadata is inconsistent for the procedure `get_version_proc` in the database `test` due to usage of special characters in procedure body. To avoid that, drop and recreate the procedure without any special characters before proceeding with the Upgrade."
      }
  ]
}
```
預先檢查會報告資料庫叢集包含 `get_version_proc` 資料庫中名為 `test` 的程序，其中包含程序本文中的特殊字元。  
捨棄並重新建立預存程序後，預先檢查會成功，讓升級繼續進行。  

```
{
  "id": "auroraUpgradeCheckForSpecialCharactersInProcedures",
  "title": "Check for inconsistency related to special characters in stored procedures.",
  "status": "OK",
  "detectedProblems": []
},
```

**auroraUpgradeCheckForSysSchemaObjectTypeMismatch**  
**預先檢查層級：錯誤**  
**檢查 `sys` 結構描述的物件類型不符**  
[sys 結構描述](https://dev.mysql.com/doc/refman/8.0/en/sys-schema.html)是 MySQL 資料庫中的一組物件和檢視，可協助使用者故障診斷、最佳化和監控其資料庫執行個體。從 Aurora MySQL 第 2 版升級至第 3 版時，`sys` 結構描述檢視會重新建立並更新為新的 Aurora MySQL 第 3 版定義。  
在升級過程中，如果 `sys` 結構描述中的任何物件是使用儲存引擎 ([INFORMATION\$1SCHEMA.TABLES](https://dev.mysql.com/doc/refman/5.7/en/information-schema-tables-table.html) 中的`sys_config/BASE TABLE`) 而非檢視來定義，則升級將會失敗。您可以在 `information_schema.tables` 資料表中找到此類資料表。這不是預期的行為，但在某些情況下，可能會因使用者錯誤而發生。  
此預先檢查會驗證所有 `sys` 結構描述物件，以確保它們使用正確的資料表定義，且檢視不會錯誤地定義為 InnoDB 或 MyISAM 資料表。若要解決問題，請重新命名或捨棄任何傳回的物件，以手動修正這些物件。然後重試升級。  
**輸出範例：**  

```
{
  "id": "auroraUpgradeCheckForSysSchemaObjectTypeMismatch",
  "title": "Check object type mismatch for sys schema.",
  "status": "OK",
  "description": "Database contains objects with type mismatch for sys schema.",
  "detectedProblems": [
      {
        "level": "Error",
        "dbObject": "sys.waits_global_by_latency",
        "description": "Your object sys.waits_global_by_latency has a type mismatch. To fix the inconsistency we recommend to rename or remove the object before upgrading (use RENAME TABLE command). "
      }
  ]
}
```
預先檢查會報告 `sys` 結構描述中的 [sys.waits\$1global\$1by\$1latency](https://dev.mysql.com/doc/refman/5.7/en/sys-waits-global-by-latency.html) 檢視的類型不符，導致無法繼續升級。  
登入資料庫執行個體後，您可以看到此物件在應該是檢視時定義為 InnoDB 資料表。  

```
mysql> show create table sys.waits_global_by_latency\G
*************************** 1. row ***************************
       Table: waits_global_by_latency
Create Table: CREATE TABLE `waits_global_by_latency` (
  `events` varchar(128) DEFAULT NULL,
  `total` bigint(20) unsigned DEFAULT NULL,
  `total_latency` text,
  `avg_latency` text,
  `max_latency` text
) ENGINE=InnoDB DEFAULT CHARSET=utf8
1 row in set (0.00 sec)
```
若要解決此問題，我們可以捨棄並重新建立具有[正確定義](https://github.com/mysql/mysql-server/blob/mysql-5.7.44/scripts/sys_schema/views/p_s/waits_global_by_latency.sql)的檢視，或將其重新命名。在升級過程中，系統會自動使用正確的資料表定義建立它。  

```
mysql> RENAME TABLE sys.waits_global_by_latency to sys.waits_global_by_latency_old;
Query OK, 0 rows affected (0.01 sec)
```
執行此操作後，預先檢查會通過。  

```
{
  "id": "auroraUpgradeCheckForSysSchemaObjectTypeMismatch",
  "title": "Check object type mismatch for sys schema.",
  "status": "OK",
  "detectedProblems": []
}
```

**auroraUpgradeCheckForViewColumnNameLength**  
**預先檢查層級：錯誤**  
**檢查檢視中資料欄名稱的上限**  
MySQL 中[允許的資料欄名稱長度上限](https://dev.mysql.com/doc/refman/5.7/en/identifier-length.html)為 64 個字元。在 MySQL 8.0 之前，在某些情況下，可以建立資料欄名稱大於 64 個字元的檢視。如果您的資料庫執行個體上存在任何此類檢視，則會傳回預先檢查錯誤，且升級將會失敗。若要允許繼續升級，您必須重新建立有問題的檢視，確保其資料欄長度小於 64 個字元。然後重試升級。  
**輸出範例：**  

```
{
  "id": "auroraUpgradeCheckForViewColumnNameLength",
  "title": "Check for upperbound limit related to column name in view.",
  "status": "OK",
  "description": "Following view(s) has column(s) with length greater than 64.",
  "detectedProblems": [
      {
        "level": "Error",
        "dbObject": "test.colname_view_test.col2_pad_pad_pad_pad_pad_pad_pad_pad_pad_pad_pad_pad_pad_pad_pad_pad_pad",
        "description": "View `test`.`colname_view_test`has column `col2_pad_pad_pad_pad_pad_pad_pad_pad_pad_pad_pad_pad_pad_pad_pad_pad_pad` with invalid column name length. To avoid Upgrade errors, view should be altered by renaming the column name so that its length is not 0 and doesn't exceed 64."
      }
  ]
}
```
預先檢查會報告 `test.colname_view_test` 檢視包含的資料欄 `col2_pad_pad_pad_pad_pad_pad_pad_pad_pad_pad_pad_pad_pad_pad_pad_pad_pad` 超過允許的資料欄長度上限 64 個字元。  
查看檢視定義，我們可以看到違規的資料欄。  

```
mysql> desc `test`.`colname_view_test`;
+------------------------------------------------------------------+-------------+------+-----+---------+-------+
| Field                                                            | Type        | Null | Key | Default | Extra |
+------------------------------------------------------------------+-------------+------+-----+---------+-------+
| col1                                                             | varchar(20) | YES  |     | NULL    |       |
| col2_pad_pad_pad_pad_pad_pad_pad_pad_pad_pad_pad_pad_pad_pad_pad | int(11)     | YES  |     | NULL    |       |
+------------------------------------------------------------------+-------------+------+-----+---------+-------+
2 rows in set (0.00 sec)
```
若要允許繼續升級，請重新建立檢視，確保資料欄長度不超過 64 個字元。  

```
mysql> drop view `test`.`colname_view_test`;
Query OK, 0 rows affected (0.01 sec)

mysql> create view `test`.`colname_view_test`(col1, col2_nopad) as select inf, fodcol from test;
Query OK, 0 rows affected (0.01 sec)

mysql> desc `test`.`colname_view_test`;
+------------+-------------+------+-----+---------+-------+
| Field      | Type        | Null | Key | Default | Extra |
+------------+-------------+------+-----+---------+-------+
| col1       | varchar(20) | YES  |     | NULL    |       |
| col2_nopad | int(11)     | YES  |     | NULL    |       |
+------------+-------------+------+-----+---------+-------+
2 rows in set (0.00 sec)
```
執行此操作後，預先檢查會成功。  

```
{
  "id": "auroraUpgradeCheckForViewColumnNameLength",
  "title": "Check for upperbound limit related to column name in view.",
  "status": "OK",
  "detectedProblems": []
}
```

**auroraUpgradeCheckIndexLengthLimitOnTinyColumns**  
**預先檢查層級：錯誤**  
**檢查在小型資料欄上定義字首長度大於 255 個位元組之索引的資料表**  
在 MySQL 中使用[二進位資料類型](https://dev.mysql.com/doc/refman/5.7/en/binary-varbinary.html)在資料欄上建立索引時，您必須在索引定義中新增[字首](https://dev.mysql.com/doc/refman/5.7/en/column-indexes.html#column-indexes-prefix)長度。在 MySQL 8.0 之前，在某些情況下，您可以指定大於此類資料類型所允許大小上限的字首長度。例如 `TINYTEXT` 和 `TINYBLOB` 欄，其中允許的資料大小上限為 255 個位元組，但允許大於此值的索引字首。如需詳細資訊，請參閱 MySQL 文件中的 [InnoDB 限制](https://dev.mysql.com/doc/refman/8.0/en/innodb-limits.html)。  
如果此預先檢查失敗，請捨棄違規的索引，或將索引的 `TINYTEXT` 和 `TINYBLOB` 欄的字首長度減少到少於 255 個位元組。然後重試升級。  
**輸出範例：**  

```
{
  "id": "auroraUpgradeCheckIndexLengthLimitOnTinyColumns",
  "title": "Check for the tables with indexes defined with prefix length greater than 255 bytes on tiny columns",
  "status": "OK",
  "description": "Prefix length of the indexes defined on tiny columns cannot exceed 255 bytes. With utf8mb4 char set, this limits the prefix length supported upto 63 characters only. A larger prefix length was allowed in MySQL5.7 using innodb_large_prefix parameter. This parameter is deprecated in MySQL 8.0.",
  "documentationLink": "https://dev.mysql.com/doc/refman/8.0/en/innodb-limits.html, https://dev.mysql.com/doc/refman/8.0/en/storage-requirements.html",
  "detectedProblems": [
      {
        "level": "Error",
        "dbObject": "test.tintxt_prefixed_index.col1",
        "description": "Index 'PRIMARY' on tinytext/tinyblob column `col1` of table `test.tintxt_prefixed_index` is defined with prefix length exceeding 255 bytes. Reduce the prefix length to <=255 bytes depending on character set used. For utf8mb4, it should be <=63."
      }
  ]
}
```
預先檢查會報告 `test.tintxt_prefixed_index` 資料表的錯誤，因為其索引 `PRIMARY` 的字首在 TINYTEXT 或 TINYBLOB 資料欄上大於 255 個位元組。  
查看此資料表的定義，我們可以看到主索引鍵在 `TINYTEXT` 資料欄 `col1` 上有 65 的字首。由於資料表是使用 `utf8mb4` 字元集來定義，每個字元可存放 4 個位元組，因此字首超過 255 個位元組的限制。  

```
mysql> show create table `test`.`tintxt_prefixed_index`\G
*************************** 1. row ***************************
       Table: tintxt_prefixed_index
Create Table: CREATE TABLE `tintxt_prefixed_index` (
  `col1` tinytext NOT NULL,
  `col2` tinytext,
  `col_id` tinytext,
  PRIMARY KEY (`col1`(65))
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC
1 row in set (0.00 sec)
```
使用 `utf8mb4` 字元集將索引字首修改為 63 將允許繼續升級。  

```
mysql> alter table `test`.`tintxt_prefixed_index` drop PRIMARY KEY, ADD  PRIMARY KEY (`col1`(63));
Query OK, 0 rows affected (0.04 sec)
Records: 0  Duplicates: 0  Warnings: 0
```
執行此操作後，預先檢查會成功。  

```
{
  "id": "auroraUpgradeCheckIndexLengthLimitOnTinyColumns",
  "title": "Check for the tables with indexes defined with prefix length greater than 255 bytes on tiny columns",
  "status": "OK",
  "detectedProblems": []
}
```

**auroraUpgradeCheckMissingInnodbMetadataForMysqlHostTable**  
**預先檢查層級：錯誤**  
**檢查 `mysql.host` 資料表缺少的 InnoDB 中繼資料不一致**  
這是 RDS 服務執行的僅限內部預先檢查。升級時會自動處理任何錯誤，並且可以安全地忽略。  
如果您在此預先檢查中遇到任何錯誤，請向 [AWS Support](https://aws.amazon.com/support) 開立案例，以請求解決中繼資料不一致的問題。或者，您可以執行邏輯傾印，然後還原至新的 Aurora MySQL 第 3 版資料庫叢集，以重試升級。

## 警告
<a name="precheck-descriptions-warnings"></a>

下列預先檢查會在預先檢查失敗時產生警告，但升級可以繼續。

**Topics**
+ [報告警告的 MySQL 預先檢查](#precheck-descriptions-warnings.mysql)
+ [報告警告的 Aurora MySQL 預先檢查](#precheck-descriptions-warnings.aurora)

### 報告警告的 MySQL 預先檢查
<a name="precheck-descriptions-warnings.mysql"></a>

下列預先檢查來自 Community MySQL：
+ [defaultAuthenticationPlugin](#defaultAuthenticationPlugin)
+ [maxdbFlagCheck](#maxdbFlagCheck)
+ [mysqlDollarSignNameCheck](#mysqlDollarSignNameCheck)
+ [reservedKeywordsCheck](#reservedKeywordsCheck)
+ [utf8mb3Check](#utf8mb3Check)
+ [zeroDatesCheck](#zeroDatesCheck)

**defaultAuthenticationPlugin**  
**預先檢查層級：警告**  
**新的預設身分驗證外掛程式考量**  
在 MySQL 8.0 中，引進了 `caching_sha2_password` 身分驗證外掛程式，提供比已棄用 `mysql_native_password` 外掛程式更安全的密碼加密和更好的效能。對於 Aurora MySQL 第 3 版，用於資料庫使用者的預設身分驗證外掛程式是 `mysql_native_password` 外掛程式。  
此預先檢查會警告將會移除此外掛程式，並在未來的主要版本發行中變更預設值。在此變更之前，請考慮評估應用程式用戶端和使用者的相容性。  
如需詳細資訊，請參閱 MySQL 文件中的 [caching\$1sha2\$1password 相容性問題和解決方案](https://dev.mysql.com/doc/refman/8.0/en/upgrading-from-previous-series.html#upgrade-caching-sha2-password-compatibility-issues)。  
**輸出範例：**  

```
{
  "id": "defaultAuthenticationPlugin",
  "title": "New default authentication plugin considerations",
  "description": "Warning: The new default authentication plugin 'caching_sha2_password' offers more secure password hashing than previously used 'mysql_native_password' (and consequent improved client connection authentication). However, it also has compatibility implications that may affect existing MySQL installations. If your MySQL installation must serve pre-8.0 clients and you encounter compatibility issues after upgrading, the simplest way to address those issues is to reconfigure the server to revert to the previous default authentication plugin (mysql_native_password). For example, use these lines in the server option file:\n\n[mysqld]\ndefault_authentication_plugin=mysql_native_password\n\nHowever, the setting should be viewed as temporary, not as a long term or permanent solution, because it causes new accounts created with the setting in effect to forego the improved authentication security.\nIf you are using replication please take time to understand how the authentication plugin changes may impact you.",
  "documentationLink": "https://dev.mysql.com/doc/refman/8.0/en/upgrading-from-previous-series.html#upgrade-caching-sha2-password-compatibility-issues\nhttps://dev.mysql.com/doc/refman/8.0/en/upgrading-from-previous-series.html#upgrade-caching-sha2-password-replication"
},
```

**maxdbFlagCheck**  
**預先檢查層級：警告**  
**使用過時的 `MAXDB` `sql_mode` 旗標**  
在 MySQL 8.0 中，[移除](https://dev.mysql.com/doc/refman/8.0/en/mysql-nutshell.html)了一些已棄用的 [sql\$1mode](https://dev.mysql.com/doc/refman/5.7/en/server-system-variables.html#sysvar_sql_mode) 系統變數選項，其中一個是 `MAXDB`。此預先檢查會檢查所有目前連線的工作階段，以及常式和觸發條件，以確保沒有任何 `sql_mode` 設定為任何包含 `MAXDB` 的組合。  
**輸出範例：**  

```
{
  "id": "maxdbFlagCheck",
  "title": "Usage of obsolete MAXDB sql_mode flag",
  "status": "OK",
  "description": "Warning: The following DB objects have the obsolete MAXDB option persisted for sql_mode, which will be cleared during the upgrade. It can potentially change the datatype DATETIME into TIMESTAMP if it is used inside object's definition, and this in turn can change the behavior in case of dates earlier than 1970 or later than 2037. If this is a concern, please redefine these objects so that they do not rely on the MAXDB flag before running the upgrade.",
  "documentationLink": "https://dev.mysql.com/doc/refman/8.0/en/mysql-nutshell.html#mysql-nutshell-removals",
  "detectedProblems": [
      {
        "level": "Warning",
        "dbObject": "test.maxdb_stored_routine",
        "description": "PROCEDURE uses obsolete MAXDB sql_mode",
        "dbObjectType": "Routine"
      }
  ]
}
```
預先檢查會報告 `test.maxdb_stored_routine` 常式包含不支援的 `sql_mode` 選項。  
登入資料庫後，您可以在 `sql_mode` 包含 `MAXDB` 的常式定義中看到。  

```
 > SHOW CREATE PROCEDURE test.maxdb_stored_routine\G

*************************** 1. row ***************************
           Procedure: maxdb_stored_routine
            sql_mode: PIPES_AS_CONCAT,ANSI_QUOTES,IGNORE_SPACE,MAXDB,NO_KEY_OPTIONS,NO_TABLE_OPTIONS,NO_FIELD_OPTIONS,NO_AUTO_CREATE_USER
    Create Procedure: CREATE DEFINER="msandbox"@"localhost" PROCEDURE "maxdb_stored_routine"()
BEGIN
    SELECT * FROM test;
END
character_set_client: utf8
collation_connection: utf8_general_ci
  Database Collation: latin1_swedish_ci
1 row in set (0.00 sec)
```
若要解決此問題，請在用戶端上設定正確的 `sql_mode` 之後重新建立程序。  
根據 [MySQL 文件](https://dev.mysql.com/doc/refman/5.7/en/create-procedure.html)，MySQL 會存放建立或修改常式時生效的 `sql_mode` 設定。無論常式啟動時的 `sql_mode` 設定為何，它一律會使用此設定執行常式。  
在變更 `sql_mode` 之前，請參閱 MySQL 文件中的[伺服器 SQL 模式](https://dev.mysql.com/doc/refman/5.7/en/sql-mode.html)。仔細評估對應用程式執行此操作的任何潛在影響。
在沒有不支援的 `sql_mode` 的情況下重新建立程序。  

```
mysql > set sql_mode='PIPES_AS_CONCAT,ANSI_QUOTES,IGNORE_SPACE';
Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql > DROP PROCEDURE test.maxdb_stored_routine\G
Query OK, 0 rows affected (0.00 sec)

mysql >
mysql > DELIMITER $$
mysql >
mysql > CREATE PROCEDURE test.maxdb_stored_routine()
    -> SQL SECURITY DEFINER
    -> BEGIN
    ->     SELECT * FROM test;
    -> END$$
Query OK, 0 rows affected (0.00 sec)

mysql >
mysql > DELIMITER ;
mysql > show create procedure test.maxdb_stored_routine\G
*************************** 1. row ***************************
           Procedure: maxdb_stored_routine
            sql_mode: PIPES_AS_CONCAT,ANSI_QUOTES,IGNORE_SPACE
    Create Procedure: CREATE DEFINER="msandbox"@"localhost" PROCEDURE "maxdb_stored_routine"()
BEGIN
    SELECT * FROM test;
END
character_set_client: utf8
collation_connection: utf8_general_ci
  Database Collation: latin1_swedish_ci
1 row in set (0.00 sec)
```
預先檢查會成功。  

```
{
  "id": "maxdbFlagCheck",
  "title": "Usage of obsolete MAXDB sql_mode flag",
  "status": "OK",
  "detectedProblems": []
}
```

**mysqlDollarSignNameCheck**  
**預先檢查層級：警告**  
**檢查物件名稱中是否已棄用單一美元符號**  
從 [MySQL 8.0.32](https://dev.mysql.com/doc/relnotes/mysql/8.0/en/news-8-0-32.html#mysqld-8-0-32-deprecation-removal) 開始，使用美元符號 (`$`) 作為未引用識別符的第一個字元已棄用。如果您有包含 `$` 作為第一個字元的任何結構描述、資料表、檢視、資料欄或常式，此預先檢查會傳回警告。雖然此警告不會阻止升級繼續進行，但我們建議您盡快採取動作來解決此問題。從 [MySQL 8.4](https://dev.mysql.com/doc/refman/8.4/en/mysql-nutshell.html)，任何此類識別符都會傳回語法錯誤，而不是警告。  
**輸出範例：**  

```
{
  "id": "mysqlDollarSignNameCheck",
  "title": "Check for deprecated usage of single dollar signs in object names",
  "status": "OK",
  "description": "Warning: The following objects have names with deprecated usage of dollar sign ($) at the begining of the identifier. To correct this warning, ensure, that names starting with dollar sign, also end with it, similary to quotes ($example$). ",
  "detectedProblems": [
      {
        "level": "Warning",
        "dbObject": "test.$deprecated_syntx",
        "description": " name starts with $ sign."
      }
  ]
},
```
預先檢查會報告警告，因為 `test` 結構描述中的 `$deprecated_syntx` 資料表包含 `$` 作為第一個字元。

**reservedKeywordsCheck**  
**預先檢查層級：警告**  
**使用名稱與新預留關鍵字衝突的資料庫物件**  
此檢查類似於 [routineSyntaxCheck](#routineSyntaxCheck)，因為它會檢查名稱與新預留關鍵字衝突的資料庫物件使用情況。雖然它們不會封鎖升級，但您需要仔細評估警告。  
**輸出範例：**  
使用上一個範例搭配名為 `except` 的資料表，預先檢查會傳回警告：  

```
{
  "id": "reservedKeywordsCheck",
  "title": "Usage of db objects with names conflicting with new reserved keywords",
  "status": "OK",
  "description": "Warning: The following objects have names that conflict with new reserved keywords. Ensure queries sent by your applications use `quotes` when referring to them or they will result in errors.",
  "documentationLink": "https://dev.mysql.com/doc/refman/en/keywords.html",
  "detectedProblems": [
      {
        "level": "Warning",
        "dbObject": "test.except",
        "description": "Table name",
        "dbObjectType": "Table"
      }
  ]
}
```
此警告可讓您知道可能有一些應用程式查詢需要檢閱。如果您的應用程式查詢未正確[逸出字串常值](https://dev.mysql.com/doc/refman/8.0/en/string-literals.html)，則升級到 MySQL 8.0 後可能會發生錯誤。檢閱您的應用程式，以確認、測試第 3 版上執行之 Aurora MySQL 資料庫叢集的複製或快照。  
升級後將失敗的非逸出應用程式查詢範例：  

```
SELECT * FROM escape;
```
升級後將成功的正確逸出應用程式查詢範例：  

```
SELECT * FROM 'escape';
```

**utf8mb3Check**  
**預先檢查層級：警告**  
**`utf8mb3` 字元集的使用**  
在 MySQL 8.0 中，`utf8mb3` 字元集已棄用，並將在未來 MySQL 主要版本中移除。如果偵測到使用此字元集的任何資料庫物件，則會實作此預先檢查以引發警告。雖然這不會阻止升級繼續進行，但強烈建議您考慮將資料表遷移到 `utf8mb4` 字元集，這是 MySQL 8.0 的預設值。如需 [utf8mb3](https://dev.mysql.com/doc/refman/8.0/en/charset-unicode-utf8mb3.html) 和 [utf8mb4](https://dev.mysql.com/doc/refman/8.0/en/charset-unicode-utf8mb4.html) 的詳細資訊，請參閱 MySQL 文件中的[在 3 位元組和 4 位元組 Unicode 字元集之間轉換](https://dev.mysql.com/doc/refman/8.0/en/charset-unicode-conversion.html)。  
**輸出範例：**  

```
{
  "id": "utf8mb3",
  "title": "Usage of utf8mb3 charset",
  "status": "OK",
  "description": "Warning: The following objects use the deprecated utf8mb3 character set. It is recommended to convert them to use utf8mb4 instead, for improved Unicode support. The utf8mb3 character is subject to removal in the future.",
  "documentationLink": "https://dev.mysql.com/doc/refman/8.0/en/charset-unicode-utf8mb3.html",
  "detectedProblems": [
      {
        "level": "Warning",
        "dbObject": "test.t1.col1",
        "description": "column's default character set: utf8",
        "dbObjectType": "Column"
      },
      {
        "level": "Warning",
        "dbObject": "test.t1.col2",
        "description": "column's default character set: utf8",
        "dbObjectType": "Column"
      }
  ]
}
```
若要解決此問題，請重建參考的物件和資料表。如需詳細資訊和先決條件，請參閱 MySQL 文件中的[在 3 位元組和 4 位元組 Unicode 字元集之間轉換](https://dev.mysql.com/doc/refman/8.0/en/charset-unicode-conversion.html)。

**zeroDatesCheck**  
**預先檢查層級：警告**  
**零日期、日期時間和時間戳記值**  
MySQL 現在會對日期、日期時間和時間戳記資料欄使用零值強制執行更嚴格的規則。我們建議您使用 `NO_ZERO_IN_DATE` 和 `NO_ZERO_DATE SQL` 模式搭配 `strict` 模式，因為它們將在未來 MySQL 版本中與 `strict` 模式合併。  
如果執行預先檢查時任何資料庫連線的 `sql_mode` 設定不包含這些模式，則預先檢查中會引發警告。使用者仍然可以插入包含零值的日期、日期時間和時間戳記值。不過，我們強烈建議將任何零值取代為有效值，因為其行為可能會在未來變更，而且可能無法正常運作。由於這是警告，因此不會封鎖升級，但建議您開始規劃以採取行動。  
**輸出範例：**  

```
{
  "id": "zeroDatesCheck",
  "title": "Zero Date, Datetime, and Timestamp values",
  "status": "OK",
  "description": "Warning: By default zero date/datetime/timestamp values are no longer allowed in MySQL, as of 5.7.8 NO_ZERO_IN_DATE and NO_ZERO_DATE are included in SQL_MODE by default. These modes should be used with strict mode as they will be merged with strict mode in a future release. If you do not include these modes in your SQL_MODE setting, you are able to insert date/datetime/timestamp values that contain zeros. It is strongly advised to replace zero values with valid ones, as they may not work correctly in the future.",
  "documentationLink": "https://lefred.be/content/mysql-8-0-and-wrong-dates/",
  "detectedProblems": [
      {
        "level": "Warning",
        "dbObject": "global.sql_mode",
        "description": "does not contain either NO_ZERO_DATE or NO_ZERO_IN_DATE which allows insertion of zero dates"
      },
      {
        "level": "Warning",
        "dbObject": "session.sql_mode",
        "description": " of 10 session(s) does not contain either NO_ZERO_DATE or NO_ZERO_IN_DATE which allows insertion of zero dates"
      }
  ]
}
```

### 報告警告的 Aurora MySQL 預先檢查
<a name="precheck-descriptions-warnings.aurora"></a>

下列預先檢查專屬於 Aurora MySQL：
+ [auroraUpgradeCheckForRollbackSegmentHistoryLength](#auroraUpgradeCheckForRollbackSegmentHistoryLength)
+ [auroraUpgradeCheckForUncommittedRowModifications](#auroraUpgradeCheckForUncommittedRowModifications)

**auroraUpgradeCheckForRollbackSegmentHistoryLength**  
**預先檢查層級：警告**  
**檢查叢集的復原區段歷史記錄清單長度是否很高**  
如 [auroraUpgradeCheckForIncompleteXATransactions](#auroraUpgradeCheckForIncompleteXATransactions) 中所述，在執行主要版本升級程序時，Aurora MySQL 第 2 版資料庫執行個體必須經過[正常關閉](https://dev.mysql.com/doc/refman/5.7/en/glossary.html#glos_slow_shutdown)。這可確保所有交易都已遞交或復原，而且 InnoDB 已清除所有復原日誌記錄。  
如果您的資料庫叢集具有高復原區段歷史記錄清單長度 (HLL)，可能會延長 InnoDB 完成復原日誌記錄清除所需的時間，導致主要版本升級程序期間延長停機時間。如果預先檢查偵測到資料庫叢集上的 HLL 很高，就會引發警告。雖然這不會阻止您的升級繼續進行，但我們建議您密切監控資料庫叢集上的 HLL。將其保持在低水準可減少主要版本升級期間所需的停機時間。如需監控 HLL 的詳細資訊，請參閱 [InnoDB 歷史記錄清單長度顯著增加](proactive-insights.history-list.md)。  
**輸出範例：**  

```
{
  "id": "auroraUpgradeCheckForRollbackSegmentHistoryLength",
  "title": "Checks if the rollback segment history length for the cluster is high",
  "status": "OK",
  "description": "Rollback Segment History length is greater than 1M. Upgrade may take longer time.",
  "detectedProblems": [
      {
        "level": "Warning",
        "dbObject": "information_schema.innodb_metrics",
        "description": "The InnoDB undo history list length('trx_rseg_history_len') is 82989114. Upgrade may take longer due to purging of undo information for old row versions."
      }
  ]
}
```
預先檢查會傳回警告，因為它偵測到資料庫叢集 (82989114) 上的 InnoDB 復原 HLL 很高。雖然升級繼續進行，但根據要清除的復原數量，它可能會延長升級程序所需的停機時間。  
我們建議您在生產環境中執行升級之前，先[調查資料庫叢集上的開啟中交易](proactive-insights.history-list.md)，以確保您的 HLL 保持在可管理的大小。

**auroraUpgradeCheckForUncommittedRowModifications**  
**預先檢查層級：警告**  
**檢查是否有許多未遞交的資料列修改**  
如 [auroraUpgradeCheckForIncompleteXATransactions](#auroraUpgradeCheckForIncompleteXATransactions) 中所述，在執行主要版本升級程序時，Aurora MySQL 第 2 版資料庫執行個體必須經過[正常關閉](https://dev.mysql.com/doc/refman/5.7/en/glossary.html#glos_slow_shutdown)。這可確保所有交易都已遞交或復原，而且 InnoDB 已清除所有復原日誌記錄。  
如果您的資料庫叢集有已修改大量資料列的交易，則可能會延長 InnoDB 在清除關機程序中完成此交易復原所需的時間。如果預先檢查找到長時間執行的交易，且資料庫叢集上有大量修改的資料列，則會引發警告。雖然這不會阻止您的升級繼續進行，但我們建議您密切監控資料庫叢集上作用中交易的大小。將其保持在低水準可減少主要版本升級期間所需的停機時間。  
**輸出範例：**  

```
{
  "id": "auroraUpgradeCheckForUncommittedRowModifications",
  "title": "Checks if there are many uncommitted modifications to rows",
  "status": "OK",
  "description": "Database contains uncommitted row changes greater than 10M. Upgrade may take longer time.",
  "detectedProblems": [
      {
        "level": "Warning",
        "dbObject": "information_schema.innodb_trx",
        "description": "The database contains 11000000 uncommitted row change(s) in 1 transaction(s). Upgrade may take longer due to transaction rollback."
      }
  ]
},
```
預先檢查會報告資料庫叢集包含具有 11,000,000 個未遞交資料列變更的交易，這些變更需要在正常關閉程序期間復原。升級會繼續進行，但為了減少升級程序期間的停機時間，建議您在生產叢集上執行升級之前監控並調查此問題。  
若要檢視寫入器資料庫執行個體上的作用中交易，您可以使用 [information\$1schema.innodb\$1trx](https://dev.mysql.com/doc/refman/5.7/en/information-schema-innodb-trx-table.html) 資料表。下列寫入器資料庫執行個體的查詢會顯示資料庫叢集目前的交易、執行時間、狀態和修改的資料列。  

```
# Example of uncommitted transaction
mysql> SELECT trx_started,
       TIME_TO_SEC(TIMEDIFF(now(), trx_started)) AS seconds_trx_has_been_running,
       trx_mysql_thread_id AS show_processlist_connection_id,
       trx_id,
       trx_state,
       trx_rows_modified AS rows_modified
FROM information_schema.innodb_trx;
+---------------------+------------------------------+--------------------------------+----------+-----------+---------------+
| trx_started         | seconds_trx_has_been_running | show_processlist_connection_id | trx_id   | trx_state | rows_modified |
+---------------------+------------------------------+--------------------------------+----------+-----------+---------------+
| 2024-08-12 18:32:52 |                         1592 |                          20041 | 52866130 | RUNNING   |      11000000 |
+---------------------+------------------------------+--------------------------------+----------+-----------+---------------+
1 row in set (0.01 sec)

# Example of transaction rolling back
mysql> SELECT trx_started,
       TIME_TO_SEC(TIMEDIFF(now(), trx_started)) AS seconds_trx_has_been_running,
       trx_mysql_thread_id AS show_processlist_connection_id,
       trx_id,
       trx_state,
       trx_rows_modified AS rows_modified
FROM information_schema.innodb_trx;
+---------------------+------------------------------+--------------------------------+----------+--------------+---------------+
| trx_started         | seconds_trx_has_been_running | show_processlist_connection_id | trx_id   | trx_state    | rows_modified |
+---------------------+------------------------------+--------------------------------+----------+--------------+---------------+
| 2024-08-12 18:32:52 |                         1719 |                          20041 | 52866130 | ROLLING BACK |      10680479 |
+---------------------+------------------------------+--------------------------------+----------+--------------+---------------+
1 row in set (0.01 sec)
```
在遞交或復原交易之後，預先檢查不會再傳回警告。在復原任何大型交易之前，請參閱 MySQL 文件和您的應用程式團隊，因為復原可能需要一些時間才能完成，具體取決於交易大小。  

```
{
  "id": "auroraUpgradeCheckForUncommittedRowModifications",
  "title": "Checks if there are many uncommitted modifications to rows",
  "status": "OK",
  "detectedProblems": []
},
```
如需有關最佳化 InnoDB 交易管理，以及在 MySQL 資料庫執行個體上執行和復原大型交易的潛在影響的詳細資訊，請參閱 MySQL 文件中的[最佳化 InnoDB 交易管理](https://dev.mysql.com/doc/refman/5.7/en/optimizing-innodb-transaction-management.html)。

## 注意
<a name="precheck-descriptions-notices"></a>

下列預先檢查會在預先檢查失敗時產生通知，但升級可以繼續。

**sqlModeFlagCheck**  
**預先檢查層級：注意**  
**使用過時的 `sql_mode` 旗標**  
除了 `MAXDB` 之外，還[移除](https://dev.mysql.com/doc/refman/8.0/en/mysql-nutshell.html)了許多其他 `sql_mode` 選項：`DB2`、`MSSQL`、`MYSQL323`、`MYSQL40``ORACLE`、`POSTGRESQL`、`NO_FIELD_OPTIONS`、`NO_KEY_OPTIONS` 和 `NO_TABLE_OPTIONS`。從 MySQL 8.0 開始，這些值都無法指派給 `sql_mode` 系統變數。如果此預先檢查使用這些 `sql_mode` 設定尋找任何開啟中工作階段，請確定已更新您的資料庫執行個體和資料庫叢集參數群組，以及用戶端應用程式和組態以停用它們。- 如需詳細資訊，請參閱 [MySQL 文件](https://dev.mysql.com/doc/refman/8.0/en/mysql-nutshell.html)。  
**輸出範例：**  

```
{
  "id": "sqlModeFlagCheck",
  "title": "Usage of obsolete sql_mode flags",
  "status": "OK",
  "detectedProblems": []
}
```
若要解決任何這些預先檢查失敗，請參閱 [maxdbFlagCheck](#maxdbFlagCheck)。

## 錯誤、警告或通知
<a name="precheck-descriptions-all"></a>

視預先檢查輸出而定，下列預先檢查可能會傳回錯誤、警告或通知。

**checkTableOutput**  
**預先檢查層級：錯誤、警告或通知**  
**`check table x for upgrade` 命令報告的問題**  
開始升級至 Aurora MySQL 第 3 版之前，`check table for upgrade` 會在資料庫叢集的使用者結構描述中的每個資料表上執行。此預先檢查與 [checkTableMysqlSchema](#checkTableMysqlSchema) 不同。  
`check table for upgrade` 命令會檢查資料表是否有任何在升級至較新版本的 MySQL 期間可能發生的潛在問題。在嘗試升級之前執行此命令有助於事先識別和解決任何不相容，使實際的升級程序更順暢。  
此命令會對每個資料表執行各種檢查，如下所示：  
+ 確認資料表結構和中繼資料是否與目標 MySQL 版本相容
+ 檢查資料表使用的任何已棄用或已移除的功能
+ 確保資料表可以正確升級，而不會遺失資料
與其他預先檢查不同，它可能會根據 `check table` 輸出傳回錯誤、警告或通知。如果此預先檢查傳回任何資料表，請在起始升級之前仔細檢閱它們，以及傳回程式碼和訊息。如需詳細資訊，請參閱 MySQL 文件中的 [CHECK TABLE 陳述式](https://dev.mysql.com/doc/refman/5.7/en/check-table.html)。  
我們在這裡提供錯誤範例和警告範例。  
**錯誤範例：**  

```
{
  "id": "checkTableOutput",
  "title": "Issues reported by 'check table x for upgrade' command",
  "status": "OK",
  "detectedProblems": [
      {
        "level": "Error",
        "dbObject": "test.parent",
        "description": "Table 'test.parent' doesn't exist"
      }
  ]
},
```
預先檢查會報告 `test.parent` 資料表不存在的錯誤。  
寫入器資料庫執行個體的 `mysql-error.log` 檔案顯示有外部索引鍵錯誤。  

```
2024-08-13T15:32:10.676893Z 62 [Warning] InnoDB: Load table `test`.`parent` failed, the table has missing foreign key indexes. Turn off 'foreign_key_checks' and try again.
2024-08-13T15:32:10.676905Z 62 [Warning] InnoDB: Cannot open table test/parent from the internal data dictionary of InnoDB though the .frm file for the table exists.
Please refer to http://dev.mysql.com/doc/refman/5.7/en/innodb-troubleshooting.html for how to resolve the issue.
```
登入寫入器資料庫執行個體並執行 `show engine innodb status\G` 以取得外部索引鍵錯誤的詳細資訊。  

```
mysql> show engine innodb status\G
*************************** 1. row ***************************
  Type: InnoDB
  Name:
Status:
=====================================
2024-08-13 15:33:33 0x14ef7b8a1700 INNODB MONITOR OUTPUT
=====================================
.
.
.
------------------------
LATEST FOREIGN KEY ERROR
------------------------
2024-08-13 15:32:10 0x14ef6dbbb700 Error in foreign key constraint of table test/child:
there is no index in referenced table which would contain
the columns as the first columns, or the data types in the
referenced table do not match the ones in table. Constraint:
,
  CONSTRAINT `fk_pname` FOREIGN KEY (`p_name`) REFERENCES `parent` (`name`)
The index in the foreign key in table is p_name_idx
Please refer to http://dev.mysql.com/doc/refman/5.7/en/innodb-foreign-key-constraints.html for correct foreign key definition.
.
.
```
`LATEST FOREIGN KEY ERROR` 訊息報告 `test.child` 資料表中參考 `test.parent` 資料表的 `fk_pname` 外部索引鍵限制條件缺少索引或資料類型不相符。有關[外部索引鍵限制條件](https://dev.mysql.com/doc/refman/5.7/en/create-table-foreign-keys.html)的 MySQL 文件指出外部索引鍵中參考的資料欄必須具有相關聯的索引，且父/子資料欄必須使用相同的資料類型。  
若要確認這是否與缺少索引或資料類型不符有關，請登入資料庫，並暫時停用工作階段變數 [foreign\$1key\$1checks](https://dev.mysql.com/doc/refman/5.7/en/create-table-foreign-keys.html#foreign-key-checks) 來檢查資料表定義。這麼做之後，我們可以看到有問題的子限制條件 (`fk_pname`) 使用 `p_name varchar(20) CHARACTER SET latin1 DEFAULT NULL` 來參考父資料表 `name varchar(20) NOT NULL`。父資料表使用 `DEFAULT CHARSET=utf8`，但子資料表的 `p_name` 資料欄使用 `latin1`，因此擲回資料類型不相符錯誤。  

```
mysql> show create table parent\G
ERROR 1146 (42S02): Table 'test.parent' doesn't exist

mysql> show create table child\G
*************************** 1. row ***************************
       Table: child
Create Table: CREATE TABLE `child` (
  `id` int(11) NOT NULL,
  `p_name` varchar(20) CHARACTER SET latin1 DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `p_name_idx` (`p_name`),
  CONSTRAINT `fk_pname` FOREIGN KEY (`p_name`) REFERENCES `parent` (`name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8
1 row in set (0.00 sec)

mysql> set foreign_key_checks=0;
Query OK, 0 rows affected (0.00 sec)

mysql> show create table parent\G
*************************** 1. row ***************************
       Table: parent
Create Table: CREATE TABLE `parent` (
  `name` varchar(20) NOT NULL,
  PRIMARY KEY (`name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8
1 row in set (0.00 sec)

mysql> show create table child\G
*************************** 1. row ***************************
       Table: child
Create Table: CREATE TABLE `child` (
  `id` int(11) NOT NULL,
  `p_name` varchar(20) CHARACTER SET latin1 DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `p_name_idx` (`p_name`),
  CONSTRAINT `fk_pname` FOREIGN KEY (`p_name`) REFERENCES `parent` (`name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8
1 row in set (0.00 sec)
```
若要解決此問題，我們可以將子資料表變更為使用與父系相同的字元集，或將父資料表變更為使用與子資料表相同的字元集。在這裡，由於子資料表在 `p_name` 資料欄定義中明確使用 `latin1`，因此我們執行 `ALTER TABLE` 將字元集修改為 `utf8`。  

```
mysql> alter table child modify p_name varchar(20) character set utf8 DEFAULT NULL;
Query OK, 0 rows affected (0.06 sec)
Records: 0  Duplicates: 0  Warnings: 0

mysql> flush tables;
Query OK, 0 rows affected (0.01 sec)
```
執行此操作後，預先檢查會通過，而且升級可以繼續。  
**警告範例：**  

```
{
  "id": "checkTableOutput",
  "title": "Issues reported by 'check table x for upgrade' command",
  "status": "OK",
  "detectedProblems": [
      {
        "level": "Warning",
        "dbObject": "test.orders",
        "description": "Trigger test.orders.delete_audit_trigg does not have CREATED attribute."
      }
  ]
}
```
預先檢查會報告 `test.orders` 資料表上 `delete_audit_trigg` 觸發條件的警告，因為它沒有 `CREATED` 屬性。根據 MySQL 文件中的[檢查版本相容性](https://dev.mysql.com/doc/refman/5.7/en/check-table.html#check-table-version-compatibility)，此訊息是資訊性的，並針對在 MySQL 5.7.2 之前建立的觸發條件進行列印。  
由於這是警告，因此不會封鎖升級繼續進行。不過，如果您想要解決問題，您可以重新建立有問題的觸發條件，而預先檢查會成功且沒有警告。  

```
{
  "id": "checkTableOutput",
  "title": "Issues reported by 'check table x for upgrade' command",
  "status": "OK",
  "detectedProblems": []
},
```

# 就地升級執行方式
<a name="AuroraMySQL.Upgrading.Procedure"></a>

建議您檢閱[Aurora MySQL 主要版本就地升級的運作方式](AuroraMySQL.Updates.MajorVersionUpgrade.md#AuroraMySQL.Upgrading.Sequence)中的背景資料。

執行任何升級前規劃和測試，如 [規劃 Aurora MySQL 叢集的主要版本升級](AuroraMySQL.Updates.MajorVersionUpgrade.md#AuroraMySQL.Upgrading.Planning) 中所述。

## 主控台
<a name="AuroraMySQL.Upgrading.ModifyingDBCluster.CON"></a>

下列範例會將 `mydbcluster-cluster` 資料庫叢集升級至 Aurora MySQL 3.04.1 版。

**升級 Aurora MySQL 資料庫叢集的主要版本**

1. 登入 AWS 管理主控台，開啟位於 [https://console.aws.amazon.com/rds/](https://console.aws.amazon.com/rds/) 的 Amazon RDS 主控台。

1. 如果您已對原始資料庫叢集使用自訂參數群組，請建立與新主要版本相容的對應參數群組。對該新參數群組中的組態參數進行任何必要的調整。如需更多詳細資訊，請參閱 [就地升級如何影響叢集的參數群組](#AuroraMySQL.Upgrading.ParamGroups)。

1.  在導覽窗格中，選擇 **Databases** (資料庫)。

1.  在清單中，選擇您要修改的資料庫叢集。

1.  選擇 **Modify (修改)**。

1.  對於 **Version** (版本)，請選擇新的 Aurora MySQL 主要版本。

   我們通常建議使用主要版本的最新次要版本。在這裡，我們選擇目前的預設版本。  
![\[將 Aurora MySQL 資料庫叢集從第 2 版就地升級至第 3 版\]](http://docs.aws.amazon.com/zh_tw/AmazonRDS/latest/AuroraUserGuide/images/ams-upgrade-v2-v3.png)

1.  選擇 **Continue (繼續)**。

1.  在下一頁中，指定執行升級的時間。選擇 **During the next scheduled maintenance window** (在下一個排程的維護期間) 或 **Immediately** (立即)。

1.  (選用) 在升級期間，定期檢查 RDS 主控台中的 **Events** (事件) 頁面。這樣做可協助您監控升級的進度，並找出任何問題。如果升級發生任何問題，請參閱 [Aurora MySQL 就地升級疑難排解](AuroraMySQL.Upgrading.Troubleshooting.md) 以了解要採取的步驟。

1. 如果您在此程序開始時建立了新的參數群組，請將自訂參數群組與升級的叢集建立關聯。如需更多詳細資訊，請參閱 [就地升級如何影響叢集的參數群組](#AuroraMySQL.Upgrading.ParamGroups)。
**注意**  
 執行此步驟需要再次啟動叢集，才能套用新的參數群組。

1.  (選用) 完成任何升級後測試後，請刪除升級開始時 Aurora 建立的手動快照。

## AWS CLI
<a name="AuroraMySQL.Upgrading.ModifyingDBCluster.CLI"></a>

若要升級 Aurora MySQL 資料庫叢集的主要版本，請使用具有下列必要參數的 AWS CLI [modify-db-cluster](https://docs.aws.amazon.com/cli/latest/reference/rds/modify-db-cluster.html) 命令：
+ `--db-cluster-identifier`
+ `--engine-version`
+ `--allow-major-version-upgrade`
+  `--apply-immediately` 或 `--no-apply-immediately` \$1

如果您的叢集使用任何自訂參數群組，也請包含下列其中一個或兩個選項：
+ `--db-cluster-parameter-group-name` (如果叢集使用自訂叢集參數群組)
+ `--db-instance-parameter-group-name` (如果叢集中的任何執行個體使用自訂資料庫參數群組)

下列範例會將 `sample-cluster` 資料庫叢集升級至 Aurora MySQL 3.04.1 版。升級會立即進行，而不是等待下一個維護時段。

**Example**  
對於 Linux、macOS 或 Unix：  

```
aws rds modify-db-cluster \
          --db-cluster-identifier sample-cluster \
          --engine-version 8.0.mysql_aurora.3.04.1 \
          --allow-major-version-upgrade \
          --apply-immediately
```
在 Windows 中：  

```
aws rds modify-db-cluster ^
          --db-cluster-identifier sample-cluster ^
          --engine-version 8.0.mysql_aurora.3.04.1 ^
          --allow-major-version-upgrade ^
          --apply-immediately
```
您可以將其他 CLI 命令與 `modify-db-cluster` 合併，建立自動化端對端程序，以執行和驗證升級。如需詳細資訊和範例，請參閱 [Aurora MySQL 會就地升級教學](AuroraMySQL.Upgrading.Tutorial.md)。

**注意**  
如果您的叢集是 Aurora 全域資料庫的一部分，就地升級程序會略有差異。呼叫 [modify-global-cluster](https://docs.aws.amazon.com/cli/latest/reference/rds/modify-global-cluster.html) 命令操作，而不是 `modify-db-cluster`。如需更多詳細資訊，請參閱 [全域資料庫的就地主要升級](#AuroraMySQL.Upgrading.GlobalDB)。

## RDS API
<a name="AuroraMySQL.Upgrading.ModifyingDBCluster.API"></a>

若要升級 Aurora MySQL 資料庫叢集的主要版本，請搭配下列必要參數使用 RDS API 操作 [ModifyDBCluster](https://docs.aws.amazon.com/AmazonRDS/latest/APIReference/API_ModifyDBCluster.html)：
+ `DBClusterIdentifier`
+ `Engine`
+ `EngineVersion`
+ `AllowMajorVersionUpgrade`
+ `ApplyImmediately` (設定為 `true` 或 `false`)

**注意**  
如果您的叢集是 Aurora 全域資料庫的一部分，就地升級程序會略有差異。呼叫 [ModifyGlobalCluster](https://docs.aws.amazon.com/AmazonRDS/latest/APIReference/API_ModifyGlobalClusterParameterGroup.html) 操作，而不是 `ModifyDBCluster`。如需更多詳細資訊，請參閱 [全域資料庫的就地主要升級](#AuroraMySQL.Upgrading.GlobalDB)。

## 就地升級如何影響叢集的參數群組
<a name="AuroraMySQL.Upgrading.ParamGroups"></a>

對於與 MySQL 5.7 或 8.0 相容的叢集，Aurora 參數群組具有不同的組態設定集。當您執行就地升級時，升級的叢集及其所有執行個體必須使用對應的叢集和執行個體參數群組。

您的叢集和執行個體可能會使用預設的 5.7 相容參數群組。若是如此，升級的叢集和執行個體會以預設的 8.0 相容參數群組開始。如果您的叢集和執行個體使用任何自訂參數群組，請務必建立對應的 8.0 相容參數群組。此外，亦請務必在升級過程中指定這些項目。

**注意**  
對於大部分參數設定，您可以在兩點選擇自訂參數群組。這些是您建立叢集或在將參數群組與叢集建立關聯時。  
不過，如果您對 `lower_case_table_names` 參數使用非預設設定，則必須預先使用此設定來設定自訂參數群組。然後，在執行快照還原來建立叢集時指定參數群組。在建立叢集之後，對 `lower_case_table_names` 參數的任何變更都無效。  
當您從 Aurora MySQL 第 2 版升級到第 3 版時，我們建議您針對 `lower_case_table_names` 使用相同的設定。  
使用以 Aurora MySQL 為基礎的 Aurora 全球資料庫時，只有將 `lower_case_table_names` 參數設為預設值並重新啟動全球資料庫，才能從 Aurora MySQL 第 2 版就地升級至第 3 版。如需詳細了解您可以使用的方法，請參閱 [主要版本升級](aurora-global-database-upgrade.md#aurora-global-database-upgrade.major)。

## 在 Aurora MySQL 版本之間對叢集屬性的變更
<a name="AuroraMySQL.Upgrading.Attrs"></a>

當您從 Aurora MySQL 第 2 版升級至第 3 版時，請務必確認用於設定或管理 Aurora MySQL 叢集和資料庫執行個體的任何應用程式或指令碼。

此外，變更操作參數群組的程式碼，以考慮預設參數群組名稱對於 5.7 和 8.0 相容叢集不同的事實。Aurora MySQL 第 2 版和第 3 版叢集的預設參數群組名稱分別為 `default.aurora-mysql5.7` 和 `default.aurora-mysql8.0`。

例如，在升級之前，可能會有如下所示的程式碼套用至叢集。

```
# Check the default parameter values for MySQL 5.7–compatible clusters.
aws rds describe-db-parameters --db-parameter-group-name default.aurora-mysql5.7 --region us-east-1
```

 升級叢集的主要版本後，如下所示修改該程式碼。

```
# Check the default parameter values for MySQL 8.0–compatible clusters.
aws rds describe-db-parameters --db-parameter-group-name default.aurora-mysql8.0 --region us-east-1
```

## 全域資料庫的就地主要升級
<a name="AuroraMySQL.Upgrading.GlobalDB"></a>

 若為 Aurora 全域資料庫，您可以升級全域資料庫叢集。Aurora 會自動同時升級所有叢集，並確保其皆執行相同的引擎版本。這項要求是因為對系統資料表、資料檔案格式等所做的任何變更都會自動複寫至所有次要叢集。

請遵循中的說明進行[Aurora MySQL 主要版本就地升級的運作方式](AuroraMySQL.Updates.MajorVersionUpgrade.md#AuroraMySQL.Upgrading.Sequence) 在您指定要升級的內容時，請確認已選擇全域資料庫叢集，而非其中包含的其中一個叢集。

若您使用 AWS 管理主控台，請選擇具有 **Global database** (全域資料庫) 角色的項目。

![\[升級全域資料庫叢集\]](http://docs.aws.amazon.com/zh_tw/AmazonRDS/latest/AuroraUserGuide/images/aurora-global-databases-major-upgrade-global-cluster.png)


 如果您使用 AWS CLI 或 RDS API，請呼叫 [modify-global-cluster](https://docs.aws.amazon.com/cli/latest/reference/rds/modify-global-cluster.html) 命令或 [ModifyGlobalCluster](https://docs.aws.amazon.com/AmazonRDS/latest/APIReference/API_ModifyGlobalCluster.html) 操作來啟動升級程序。您會使用其中一個，而不是 `modify-db-cluster` 或 `ModifyDBCluster`。

**注意**  
在執行 Aurora 全球資料庫的主要版本升級時，無法為全域資料庫叢集指定自訂參數群組。在全域叢集的每個區域中建立您的自訂參數群組。然後，在升級後手動將其套用至區域叢集。

 若要透過使用 AWS CLI 來升級 Aurora MySQL 全球資料庫叢集的主要版本，請使用具有下列必要參數的 [modify-global-cluster](https://docs.aws.amazon.com/cli/latest/reference/rds/modify-global-cluster.html) 命令：
+  `--global-cluster-identifier` 
+  `--engine aurora-mysql` 
+  `--engine-version` 
+  `--allow-major-version-upgrade` 

下列範例會將全球資料庫叢集升級至 Aurora MySQL 3.04.2 版。

**Example**  
對於 Linux、macOS 或 Unix：  

```
aws rds modify-global-cluster \
          --global-cluster-identifier global_cluster_identifier \
          --engine aurora-mysql \
          --engine-version 8.0.mysql_aurora.3.04.2 \
          --allow-major-version-upgrade
```
在 Windows 中：  

```
aws rds modify-global-cluster ^
          --global-cluster-identifier global_cluster_identifier ^
          --engine aurora-mysql ^
          --engine-version 8.0.mysql_aurora.3.04.2 ^
          --allow-major-version-upgrade
```

## 使用跨區域僅供讀取複本進行資料庫叢集就地升級
<a name="AuroraMySQL.Upgrading.XRRR"></a>

您可以使用就地升級程序升級具有跨區域僅供讀取複本的 Aurora 資料庫叢集，但有一些考量：
+ 您必須先升級僅供讀取複本資料庫叢集。如果您嘗試先升級主要叢集，您會收到錯誤訊息，如下所示：

  無法升級資料庫叢集 test-xr-primary-cluster，因為關聯的 Aurora 跨區域複本 test-xr-replica-cluster 尚未修補。請升級 Aurora 跨區域複本，然後再試一次。

  這表示主要資料庫叢集的資料庫引擎版本不能高於複本叢集。
+ 升級主要資料庫叢集之前，請先停止寫入工作負載，並停用對主要叢集寫入器資料庫執行個體的任何新連線請求。
+ 當您升級主要叢集時，請選擇自訂資料庫叢集參數群組，並將 `binlog_format` 參數設定為支援二進位記錄複寫的值，例如 `MIXED`。

  如需搭配 Aurora MySQL 使用二進位記錄的詳細資訊，請參閱 [Aurora 與 MySQL 之間或 Aurora 與另一個 Aurora 資料庫叢集之間的複寫 (二進位複寫)](AuroraMySQL.Replication.MySQL.md)。如需修改 Aurora MySQL 組態參數的詳細資訊，請參閱 [Aurora MySQL 組態參數](AuroraMySQL.Reference.ParameterGroups.md) 和 [Amazon Aurora 的參數群組](USER_WorkingWithParamGroups.md)。
+ 升級複本叢集之後，請勿等待很長的時間才升級主要資料庫叢集。我們建議不要等待超過下一個維護時段。
+ 升級主要資料庫叢集之後，請重新啟動其寫入器資料庫執行個體。在寫入器資料庫執行個體重新啟動之前，啟用 binlog 複寫的自訂資料庫叢集參數群組不會生效。
+ 在您確認跨區域複寫已重新啟動，且次要 AWS 區域 中的複本延遲為 0 之前，請勿繼續寫入工作負載或啟用寫入器資料庫執行個體的連線。

# Aurora MySQL 會就地升級教學
<a name="AuroraMySQL.Upgrading.Tutorial"></a>

下列 Linux 範例顯示如何使用 AWS CLI 來執行就地升級程序的一般步驟。

這第一個範例會建立執行 2.x 版 Aurora MySQL 的 Aurora 資料庫叢集。叢集包含寫入器資料庫執行個體和讀取器資料庫執行個體。`wait db-instance-available` 命令會暫停，直至寫入器資料庫執行個體可供使用為止。這正是叢集準備好升級之時。

```
aws rds create-db-cluster --db-cluster-identifier mynewdbcluster --engine aurora-mysql \
  --db-cluster-version 5.7.mysql_aurora.2.11.2
...
aws rds create-db-instance --db-instance-identifier mynewdbcluster-instance1 \
  --db-cluster-identifier mynewdbcluster --db-instance-class db.t4g.medium --engine aurora-mysql
...
aws rds wait db-instance-available --db-instance-identifier mynewdbcluster-instance1
```

您可以升級叢集的 Aurora MySQL 3.x 版本取決於叢集目前執行的 2.x 版本，以及叢集所在的 AWS 區域。使用第一個命令 `--output text`，只是顯示可用的目標版本。第二個命令顯示回應的完整 JSON 輸出。在該回應中，您可以查看詳細資訊，例如用於 `engine` 參數的 `aurora-mysql` 值。您還可以查看升級至 3.04.0 代表主要版本升級的事實。

```
aws rds describe-db-clusters --db-cluster-identifier mynewdbcluster \
  --query '*[].{EngineVersion:EngineVersion}' --output text
5.7.mysql_aurora.2.11.2

aws rds describe-db-engine-versions --engine aurora-mysql --engine-version 5.7.mysql_aurora.2.11.2 \
  --query '*[].[ValidUpgradeTarget]'
...
{
    "Engine": "aurora-mysql",
    "EngineVersion": "8.0.mysql_aurora.3.04.0",
    "Description": "Aurora MySQL 3.04.0 (compatible with MySQL 8.0.28)",
    "AutoUpgrade": false,
    "IsMajorVersionUpgrade": true,
    "SupportedEngineModes": [
        "provisioned"
    ],
    "SupportsParallelQuery": true,
    "SupportsGlobalDatabases": true,
    "SupportsBabelfish": false,
    "SupportsIntegrations": false
},
...
```

此範例說明，如果您輸入的目標版本編號不是叢集的有效升級目標，Aurora 不會執行升級。Aurora 也不會執行主要版本升級，除非您包含 `--allow-major-version-upgrade` 參數。如此一來，您就不會意外執行可能需要對應用程式的程式碼進行大量測試和變更的升級。

```
aws rds modify-db-cluster --db-cluster-identifier mynewdbcluster \
  --engine-version 5.7.mysql_aurora.2.09.2 --apply-immediately
An error occurred (InvalidParameterCombination) when calling the ModifyDBCluster operation: Cannot find upgrade target from 5.7.mysql_aurora.2.11.2 with requested version 5.7.mysql_aurora.2.09.2.

aws rds modify-db-cluster --db-cluster-identifier mynewdbcluster \
  --engine-version 8.0.mysql_aurora.3.04.0 --region us-east-1 --apply-immediately
An error occurred (InvalidParameterCombination) when calling the ModifyDBCluster operation: The AllowMajorVersionUpgrade flag must be present when upgrading to a new major version.

aws rds modify-db-cluster --db-cluster-identifier mynewdbcluster \
  --engine-version 8.0.mysql_aurora.3.04.0 --apply-immediately --allow-major-version-upgrade
{
  "DBClusterIdentifier": "mynewdbcluster",
  "Status": "available",
  "Engine": "aurora-mysql",
  "EngineVersion": "5.7.mysql_aurora.2.11.2"
}
```

 叢集和相關資料庫執行個體的狀態需要一段時間才能變更為 `upgrading`。叢集和資料庫執行個體的版本編號只有在升級完成時才會變更。同樣，您可以使用寫入器資料庫執行個體的 `wait db-instance-available` 命令，等到升級完成後再繼續進行。

```
aws rds describe-db-clusters --db-cluster-identifier mynewdbcluster \
  --query '*[].[Status,EngineVersion]' --output text
upgrading 5.7.mysql_aurora.2.11.2

aws rds describe-db-instances --db-instance-identifier mynewdbcluster-instance1 \
  --query '*[].{DBInstanceIdentifier:DBInstanceIdentifier,DBInstanceStatus:DBInstanceStatus} | [0]'
{
    "DBInstanceIdentifier": "mynewdbcluster-instance1",
    "DBInstanceStatus": "upgrading"
}

aws rds wait db-instance-available --db-instance-identifier mynewdbcluster-instance1
```

 此時，叢集的版本編號符合針對升級指定的版本編號。

```
aws rds describe-db-clusters --db-cluster-identifier mynewdbcluster \
  --query '*[].[EngineVersion]' --output text

8.0.mysql_aurora.3.04.0
```

上述範例透過指定 `--apply-immediately` 參數立即執行升級。若要讓升級在方便的時間，當叢集不忙碌時發生，您可以指定 `--no-apply-immediately` 參數。這樣做會在叢集的下一個維護時段期間啟動升級。維護時段會定義維護操作可以開始的期間。長時間執行的操作可能無法在維護時段完成。因此，即使您預期升級可能需要很長時間，也不需要定義較大的維護時段。

下列範例會升級最初執行 Aurora MySQL 2.11.2 版的叢集。在 `describe-db-engine-versions` 輸出中，`False` 和 `True` 值表示 `IsMajorVersionUpgrade` 屬性。從 2.11.2 版開始，您可以升級至其他 2.\$1 版本。這些升級不會視為主要版本升級，因此不需要就地升級。就地升級僅適用於升級至清單中顯示的 3.\$1 版。

```
aws rds describe-db-clusters --db-cluster-identifier mynewdbcluster \
  --query '*[].{EngineVersion:EngineVersion}' --output text
5.7.mysql_aurora.2.11.2

aws rds describe-db-engine-versions --engine aurora-mysql --engine-version 5.7.mysql_aurora.2.10.2 \
  --query '*[].[ValidUpgradeTarget]|[0][0]|[*].[EngineVersion,IsMajorVersionUpgrade]' --output text

5.7.mysql_aurora.2.11.3 False
5.7.mysql_aurora.2.11.4 False
5.7.mysql_aurora.2.11.5 False
5.7.mysql_aurora.2.11.6 False
5.7.mysql_aurora.2.12.0 False
5.7.mysql_aurora.2.12.1 False
5.7.mysql_aurora.2.12.2 False
5.7.mysql_aurora.2.12.3 False
8.0.mysql_aurora.3.04.0 True
8.0.mysql_aurora.3.04.1 True
8.0.mysql_aurora.3.04.2 True
8.0.mysql_aurora.3.04.3 True
8.0.mysql_aurora.3.05.2 True
8.0.mysql_aurora.3.06.0 True
8.0.mysql_aurora.3.06.1 True
8.0.mysql_aurora.3.07.1 True

aws rds modify-db-cluster --db-cluster-identifier mynewdbcluster \
  --engine-version 8.0.mysql_aurora.3.04.0 --no-apply-immediately --allow-major-version-upgrade
...
```

在沒有指定維護時段的情況下建立叢集時，Aurora 會隨機挑選一週中的一天。在這種情況下，`modify-db-cluster` 命令會在週一提交。因此，我們將維護時段變更為週二上午。所有時間都以 UTC 時區表示。`tue:10:00-tue:10:30` 時段對應於太平洋時間上午 2:00-2:30。維護時段中的變更會立即生效。

```
aws rds describe-db-clusters --db-cluster-identifier mynewdbcluster --query '*[].[PreferredMaintenanceWindow]'
[
    [
        "sat:08:20-sat:08:50"
    ]
]

aws rds modify-db-cluster --db-cluster-identifier mynewdbcluster --preferred-maintenance-window tue:10:00-tue:10:30"
aws rds describe-db-clusters --db-cluster-identifier mynewdbcluster --query '*[].[PreferredMaintenanceWindow]'
[
    [
        "tue:10:00-tue:10:30"
    ]
]
```

下列範例顯示如何取得升級產生事件的報告。`--duration` 引數代表擷取事件資訊的分鐘數。此引數是必要的，因為根據預設，`describe-events` 僅傳回最後一小時的事件。

```
aws rds describe-events --source-type db-cluster --source-identifier mynewdbcluster --duration 20160
{
    "Events": [
        {
            "SourceIdentifier": "mynewdbcluster",
            "SourceType": "db-cluster",
            "Message": "DB cluster created",
            "EventCategories": [
                "creation"
            ],
            "Date": "2022-11-17T01:24:11.093000+00:00",
            "SourceArn": "arn:aws:rds:us-east-1:123456789012:cluster:mynewdbcluster"
        },
        {
            "SourceIdentifier": "mynewdbcluster",
            "SourceType": "db-cluster",
            "Message": "Upgrade in progress: Performing online pre-upgrade checks.",
            "EventCategories": [
                "maintenance"
            ],
            "Date": "2022-11-18T22:57:08.450000+00:00",
            "SourceArn": "arn:aws:rds:us-east-1:123456789012:cluster:mynewdbcluster"
        },
        {
            "SourceIdentifier": "mynewdbcluster",
            "SourceType": "db-cluster",
            "Message": "Upgrade in progress: Performing offline pre-upgrade checks.",
            "EventCategories": [
                "maintenance"
            ],
            "Date": "2022-11-18T22:57:59.519000+00:00",
            "SourceArn": "arn:aws:rds:us-east-1:123456789012:cluster:mynewdbcluster"
        },
        {
            "SourceIdentifier": "mynewdbcluster",
            "SourceType": "db-cluster",
            "Message": "Upgrade in progress: Creating pre-upgrade snapshot [preupgrade-mynewdbcluster-5-7-mysql-aurora-2-10-2-to-8-0-mysql-aurora-3-02-0-2022-11-18-22-55].",
            "EventCategories": [
                "maintenance"
            ],
            "Date": "2022-11-18T23:00:22.318000+00:00",
            "SourceArn": "arn:aws:rds:us-east-1:123456789012:cluster:mynewdbcluster"
        },
        {
            "SourceIdentifier": "mynewdbcluster",
            "SourceType": "db-cluster",
            "Message": "Upgrade in progress: Cloning volume.",
            "EventCategories": [
                "maintenance"
            ],
            "Date": "2022-11-18T23:01:45.428000+00:00",
            "SourceArn": "arn:aws:rds:us-east-1:123456789012:cluster:mynewdbcluster"
        },
        {
            "SourceIdentifier": "mynewdbcluster",
            "SourceType": "db-cluster",
            "Message": "Upgrade in progress: Purging undo records for old row versions. Records remaining: 164",
            "EventCategories": [
                "maintenance"
            ],
            "Date": "2022-11-18T23:02:25.141000+00:00",
            "SourceArn": "arn:aws:rds:us-east-1:123456789012:cluster:mynewdbcluster"
        },
        {
            "SourceIdentifier": "mynewdbcluster",
            "SourceType": "db-cluster",
            "Message": "Upgrade in progress: Purging undo records for old row versions. Records remaining: 164",
            "EventCategories": [
                "maintenance"
            ],
            "Date": "2022-11-18T23:06:23.036000+00:00",
            "SourceArn": "arn:aws:rds:us-east-1:123456789012:cluster:mynewdbcluster"
        },
        {
            "SourceIdentifier": "mynewdbcluster",
            "SourceType": "db-cluster",
            "Message": "Upgrade in progress: Upgrading database objects.",
            "EventCategories": [
                "maintenance"
            ],
            "Date": "2022-11-18T23:06:48.208000+00:00",
            "SourceArn": "arn:aws:rds:us-east-1:123456789012:cluster:mynewdbcluster"
        },
        {
            "SourceIdentifier": "mynewdbcluster",
            "SourceType": "db-cluster",
            "Message": "Database cluster major version has been upgraded",
            "EventCategories": [
                "maintenance"
            ],
            "Date": "2022-11-18T23:10:28.999000+00:00",
            "SourceArn": "arn:aws:rds:us-east-1:123456789012:cluster:mynewdbcluster"
        }
    ]
}
```

# 尋找 Aurora MySQL 主要版本升級失敗的原因
<a name="AuroraMySQL.Upgrading.failure-events"></a>

在[教學課程](AuroraMySQL.Upgrading.Tutorial.md)中，從 Aurora MySQL 第 2 版升級至第 3 版成功。但是，如果升級失敗，您會想知道原因。

您可以從使用 `describe-events` AWS CLI 命令開始查看資料庫叢集事件。此範例顯示過去 10 小時內 `mydbcluster` 的事件。

```
aws rds describe-events \
    --source-type db-cluster \
    --source-identifier mydbcluster \
    --duration 600
```

在這種情況下，我們發生升級預先檢查失敗。

```
{
    "Events": [
        {
            "SourceIdentifier": "mydbcluster",
            "SourceType": "db-cluster",
            "Message": "Database cluster engine version upgrade started.",
            "EventCategories": [
                "maintenance"
            ],
            "Date": "2024-04-11T13:23:22.846000+00:00",
            "SourceArn": "arn:aws:rds:us-east-1:123456789012:cluster:mydbcluster"
        },
        {
            "SourceIdentifier": "mydbcluster",
            "SourceType": "db-cluster",
            "Message": "Database cluster is in a state that cannot be upgraded: Upgrade prechecks failed. For more details, see the  
             upgrade-prechecks.log file. For more information on troubleshooting the cause of the upgrade failure, see 
             https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/AuroraMySQL.Upgrading.Troubleshooting.html",
            "EventCategories": [
                "maintenance"
            ],
            "Date": "2024-04-11T13:23:24.373000+00:00",
            "SourceArn": "arn:aws:rds:us-east-1:123456789012:cluster:mydbcluster"
        }
    ]
}
```

若要診斷問題的確切原因，請檢查寫入器資料庫執行個體的資料庫日誌。升級到 Aurora MySQL 第 3 版失敗時，寫入器執行個體會包含一個日誌檔案，名稱為 `upgrade-prechecks.log`。此範例說明如何偵測該日誌是否存在，然後將其下載為本機檔案進行檢查。

```
aws rds describe-db-log-files --db-instance-identifier mydbcluster-instance \
    --query '*[].[LogFileName]' --output text

error/mysql-error-running.log
error/mysql-error-running.log.2024-04-11.20
error/mysql-error-running.log.2024-04-11.21
error/mysql-error.log
external/mysql-external.log
upgrade-prechecks.log

aws rds download-db-log-file-portion --db-instance-identifier mydbcluster-instance \
    --log-file-name upgrade-prechecks.log \
    --starting-token 0 \
    --output text >upgrade_prechecks.log
```

`upgrade-prechecks.log` 檔案為 JSON 格式。我們使用 `--output text` 選項來下載檔案，避免在另一個 JSON 包裝函式中對 JSON 輸出進行編碼。針對 Aurora MySQL 第 3 版升級，此日誌一律包含特定資訊和警告訊息。它只會在升級失敗時包含錯誤訊息。如果升級成功，則根本不會產生日誌檔案。

若要摘要所有錯誤並顯示關聯的物件和描述欄位，您可以對 `upgrade-prechecks.log` 檔案的內容執行命令 `grep -A 2 '"level": "Error"'`。這麼做會顯示每個錯誤行及其後兩行。其中包含對應資料庫物件的名稱，以及如何修正問題的指引。

```
$ cat upgrade-prechecks.log | grep -A 2 '"level": "Error"'

"level": "Error",
"dbObject": "problematic_upgrade.dangling_fulltext_index",
"description": "Table `problematic_upgrade.dangling_fulltext_index` contains dangling FULLTEXT index. Kindly recreate the table before upgrade."
```

在此範例中，您可以在違規的資料表上執行下列 SQL 命令，嘗試修正問題，也可以在沒有懸置索引的情況下重新建立資料表。

```
OPTIMIZE TABLE problematic_upgrade.dangling_fulltext_index;
```

然後重試升級。

# Aurora MySQL 就地升級疑難排解
<a name="AuroraMySQL.Upgrading.Troubleshooting"></a>

使用下列提示有助於對 Aurora MySQL 就地升級的問題進行疑難排解。這些提示不適用於 Aurora Serverless 資料庫叢集。


| 就地升級被取消或緩慢的原因 | Effect | 允許在維護時段完成就地升級的解決方案 | 
| --- | --- | --- | 
| 相關聯的 Aurora 跨區域複本尚未修補 | Aurora 會取消升級。 | 請升級 Aurora 跨區域複本，然後再試一次。 | 
| 叢集的 XA 交易處於準備狀態 | Aurora 會取消升級。 | 遞交或復原所有準備好的 XA 交易。 | 
| 叢集正在處理任何資料定義語言 (DDL) 陳述式 | Aurora 會取消升級。 | 在所有 DDL 陳述式完成後，請等待並執行升級。 | 
| 叢集中的多行有未遞交的變更 | 升級可能需要很長時間。 |  升級程序會復原未遞交的變更。此條件的指標為 `TRX_ROWS_MODIFIED` 資料表 `INFORMATION_SCHEMA.INNODB_TRX` 中的值。 僅在遞交或復原所有大型交易之後，才考慮執行升級。  | 
| 叢集具有大量的復原記錄 | 升級可能需要很長時間。 |  即使未遞交的交易不會影響大量的資料列，也可能會涉及大量資料。例如，您可能插入大型 BLOB。Aurora 不會自動偵測或產生這種交易活動的事件。此情況的指標為歷史記錄清單長度 (HLL)。升級程序會復原未遞交的變更。 您可以從 `SHOW ENGINE INNODB STATUS` SQL 命令檢查輸出中的 HLL，或直接使用以下 SQL 查詢： <pre>SELECT count FROM information_schema.innodb_metrics WHERE name = 'trx_rseg_history_len';</pre> 您也可以在 Amazon CloudWatch 中監控 `RollbackSegmentHistoryListLength` 指標。 僅在 HLL 減小之後，才考慮執行升級。  | 
| 叢集正在遞交大型二進位日誌交易 | 升級可能需要很長時間。 |  升級程序會等到套用二進位日誌變更之後。在此期間，可能會啟動更多交易或 DDL 陳述式，進一步降低升級程序的速度。 在叢集不忙於產生二進位日誌複寫變更時排程升級程序。Aurora 不會自動偵測或產生此條件的事件。  | 
| 因檔案移除或損毀所導致的結構描述不一致 | Aurora 會取消升級。 |  將暫存資料表的預設儲存引擎從 MyISAM 變更為 InnoDB。執行以下步驟： [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/AmazonRDS/latest/AuroraUserGuide/AuroraMySQL.Upgrading.Troubleshooting.html)  | 
| 主要使用者已刪除 | Aurora 會取消升級。 |   請勿刪除主要使用者。  不過，如果由於某些原因，您應該刪除主要使用者，並使用下列 SQL 命令進行還原： <pre>CREATE USER 'master_username'@'%' IDENTIFIED BY 'master_user_password' REQUIRE NONE PASSWORD EXPIRE DEFAULT ACCOUNT UNLOCK;<br /><br />GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, RELOAD, PROCESS, REFERENCES, INDEX, ALTER, SHOW DATABASES, CREATE TEMPORARY TABLES, <br />LOCK TABLES, EXECUTE, REPLICATION SLAVE, REPLICATION CLIENT, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, CREATE USER, EVENT, <br />TRIGGER, LOAD FROM S3, SELECT INTO S3, INVOKE LAMBDA, INVOKE SAGEMAKER, INVOKE COMPREHEND ON *.* TO 'master_username'@'%' WITH GRANT OPTION;</pre>  | 

如需故障診斷導致升級預先檢查失敗之問題的詳細資訊，請參閱下列部落格：
+ [Amazon Aurora MySQL 第 2 版 (與 MySQL 5.7 相容) 到第 3 版 (與 MySQL 8.0 相容) 升級檢查清單，第 1 部分](https://aws.amazon.com/blogs/database/amazon-aurora-mysql-version-2-with-mysql-5-7-compatibility-to-version-3-with-mysql-8-0-compatibility-upgrade-checklist-part-1/)
+ [Amazon Aurora MySQL 第 2 版 (與 MySQL 5.7 相容) 到第 3 版 (與 MySQL 8.0 相容) 升級檢查清單，第 2 部分](https://aws.amazon.com/blogs/database/amazon-aurora-mysql-version-2-with-mysql-5-7-compatibility-to-version-3-with-mysql-8-0-compatibility-upgrade-checklist-part-2/)

 您可以使用下列步驟，對以上資料表中的某些條件執行自己的檢查。如此一來，在您知道資料庫處於升級可以順利且快速完成的狀態時，即可排程升級。
+  您可以執行 `XA RECOVER` 陳述式，來檢查開啟的 XA 交易。您隨後可以遞交或復原 XA 交易，再開始升級。
+  您可以執行 `SHOW PROCESSLIST` 陳述式，然後在輸出中尋找 `CREATE`、`DROP`、`ALTER`、`RENAME` 和 `TRUNCATE`，來檢查 DDL 陳述式。在開始升級之前，允許所有 DDL 陳述式完成。
+  您可以查詢 `INFORMATION_SCHEMA.INNODB_TRX` 資料表，檢查未遞交列的總數。該資料表包含每項交易的一個資料列。`TRX_ROWS_MODIFIED` 資料欄包含交易修改或插入的列數。
+  您可以執行 `SHOW ENGINE INNODB STATUS SQL` 陳述式，然後在輸出中尋找 `History list length`，來檢查 InnoDB 歷史記錄清單的長度。您還可以直接執行下列查詢來檢查值：

  ```
  SELECT count FROM information_schema.innodb_metrics WHERE name = 'trx_rseg_history_len';
  ```

   歷史記錄清單的長度對應於資料庫存放的還原資訊量，以實作多版本並行控制 (MVCC)。

# Aurora MySQL 第 3 版的升級後清除
<a name="AuroraMySQL.mysql80-post-upgrade"></a>

完成將任何 Aurora MySQL 第 2 版叢集升級至 Aurora MySQL 第 3 版之後，您可以執行下列其他清除動作：
+ 為任何自訂參數群組建立新的 MySQL 8.0 相容版本。將任何必要的自訂參數值套用至新的參數群組。
+ 更新任何 CloudWatch 警示、設定指令碼等，以針對其名稱受到包容性語言變更影響的任何指標使用新名稱。如需這類指標的清單，請參閱 [Aurora MySQL 第 3 版的包容性語言變更](AuroraMySQL.Compare-v2-v3.md#AuroraMySQL.8.0-inclusive-language)。
+ 更新任何 CloudFormation 範本，針對其名稱受到包容性語言變更影響的任何組態參數使用新名稱。如需這類參數的清單，請參閱 [Aurora MySQL 第 3 版的包容性語言變更](AuroraMySQL.Compare-v2-v3.md#AuroraMySQL.8.0-inclusive-language)。

## 空間索引
<a name="AuroraMySQL.mysql80-spatial"></a>

升級至 Aurora MySQL 第 3 版之後，請檢查您是否需要捨棄或重新建立與空間索引相關的物件和索引。在 MySQL 8.0 之前，Aurora 可以使用不包含空間資源識別符 (SRID) 的索引來最佳化空間查詢。Aurora MySQL 第 3 版只使用包含 SRID 的空間索引。在升級期間，Aurora 會自動捨棄任何沒有 SRID 的空間索引，並在資料庫日誌中列印警告訊息。如果您觀察到這類警告訊息，請在升級之後使用 SRID 建立新的空間索引。如需 MySQL 8.0 中對空間函數和資料類型之變更的詳細資訊，請參閱《MySQL 參考手冊》**中的 [MySQL 8.0 中的變更](https://dev.mysql.com/doc/refman/8.0/en/upgrading-from-previous-series.html)。