

# 升级 Amazon Aurora MySQL 数据库集群的主要版本
升级 Aurora MySQL 数据库集群的主要版本<a name="mvu"></a>

在诸如 3.04.1 的 Aurora MySQL 版本号中，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)
  + [

## 社区 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.Backtrack)
+ [

# 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


如果您有一个与 MySQL 5.7 兼容的集群，并希望将其升级到与 MySQL 8.0 兼容的集群，可以通过在集群本身上运行升级过程来实现。这种升级是*就地升级*，与您通过创建新集群进行的升级形成鲜明对比。此技术会保留集群的相同终端节点和其他特征。升级速度相对较快，因为它不需要将所有数据复制到新的集群卷。此稳定性有助于显著减少应用程序中的任何配置更改。它还有助于减少升级后集群的测试量。这是因为数据库实例的数量及其实例类都保持不变。

就地升级机制会在进行操作的过程中关闭您的数据库集群。Aurora 将执行正常关机，并完成进行中的操作（例如事务回滚和撤消清除）。有关更多信息，请参阅 [Aurora MySQL 主要版本就地升级的工作原理](#AuroraMySQL.Upgrading.Sequence)。

就地升级方法非常方便，因为它执行过程简单，并且可以显著减少对关联应用程序的配置更改。例如，就地升级会为集群保留终端节点和数据库实例集。但是，就地升级所需的时间可能会有所不同，具体取决于架构的属性和集群的繁忙程度。这样，根据集群的需求，您可以在多种升级技术间进行选择：
+ [就地升级](AuroraMySQL.Upgrading.Procedure.md)
+ [蓝绿部署](#AuroraMySQL.UpgradingMajor.BlueGreen)
+ [快照还原](aurora-restore-snapshot.md)
**注意**  
如果您使用 Amazon CLI 或 RDS API 作为快照还原升级方法，则必须运行后续操作才能在还原的数据库集群中创建写入器数据库实例。

有关 Aurora MySQL 版本 3 及其新功能的一般信息，请参阅 [与 MySQL 8.0 兼容的 Aurora MySQL 版本 3](AuroraMySQL.MySQL80.md)。

有关计划升级的详细信息，请参阅 [为 Aurora MySQL 集群计划主要版本升级](#AuroraMySQL.Upgrading.Planning) 和 [如何执行就地升级](AuroraMySQL.Upgrading.Procedure.md)。

## Aurora MySQL 主要版本升级路径


并非所有类型或版本的 Aurora MySQL 集群都可以使用就地升级机制。通过查阅下表，您可以了解每个 Aurora MySQL 集群的适当升级路径。


|  Aurora MySQL 数据库集群类型  | 它可以使用就地升级吗？  |  Action  | 
| --- | --- | --- | 
|   Aurora MySQL 预置集群，版本 2  |  是  |  与 MySQL 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 集群  |  不适用  |  只有 Aurora MySQL 版本 2 才支持 Aurora Serverless v1。  | 
|  Aurora Serverless v2 集群  |  不适用  | 只有 Aurora MySQL 版本 3 才支持 Aurora Serverless v2。 | 
|  Aurora Global Database 中的集群  |  是  |  要将 Aurora MySQL 从版本 2 升级到版本 3，请按照对 Aurora Global Database 中的集群[进行就地升级的过程](AuroraMySQL.Upgrading.Procedure.md)操作。在全局集群上执行升级。Aurora 会同时升级全局数据库中的主集群以及所有辅助集群。 如果您使用 Amazon 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 for MySQL 或本地 MySQL 数据库实例，则无法执行升级。在这种情况下，您可以使用快照还原机制进行升级。  | 
|  具有零数据库实例的集群  |  否  |  使用 Amazon CLI 或 RDS API，您可以在没有任何附加的数据库实例的情况下创建 Aurora MySQL 集群。同样，您还可以从 Aurora MySQL 集群中删除所有数据库实例，同时保持集群卷中的数据不变。虽然集群的数据库实例为零，但您无法执行就地升级。 升级机制要求集群中的写入器实例对系统表、数据文件等执行转换。在这种情况下，请使用 Amazon CLI 或 RDS API 为集群创建写入器实例。然后你可以执行就地升级。  | 
|  启用了回溯的集群  |  是  |  可以对使用回溯功能的 Aurora MySQL 集群执行就地升级。但是，升级后，您无法将集群回溯到升级之前的时间。  | 

## Aurora MySQL 主要版本就地升级的工作原理


 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 集群计划主要版本升级


为了帮助您决定正确的升级时间和方法，您可以了解 Aurora MySQL 版本 3 与当前环境之间的区别：
+ 如果您要从 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 社区版中引入的新保留关键字的使用情况。请在升级之前执行此操作。有关更多信息，请参阅 MySQL 文档中的 [MySQL 8.0 新关键字和保留关键字](https://dev.mysql.com/doc/mysqld-version-reference/en/keywords-8-0.html#keywords-new-in-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) 中的升级后步骤进行操作。最后，测试应用程序的功能和性能。

如果您要从 MySQL 或社区 MySQL 进行 RDS 转换，请按照[将数据迁移到 Amazon Aurora MySQL 数据库集群](AuroraMySQL.Migrating.md)中所述的迁移过程进行操作。在某些情况下，作为迁移的一部分，您可以使用二进制日志复制将数据与 Aurora MySQL 版本 3 集群同步数据。如果是这样，源系统必须运行与目标数据库集群兼容的版本。

为了确保在主要版本之间升级集群后，您的应用程序和管理过程能够顺利运行，应进行一些预先计划和准备。要查看可为您的 Amazon 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 的一般可接受值为 100000 或更小。有关更多信息，请参阅此[博客文章](https://www.amazonaws.cn/blogs/database/amazon-aurora-mysql-version-2-with-mysql-5-7-compatibility-to-version-3-with-mysql-8-0-compatibility-upgrade-checklist-part-2)。

### 通过克隆数据库集群来模拟升级


您可以检查升级后集群的应用程序兼容性、性能、维护过程以及类似注意事项。为此，您可以在真正进行升级之前执行升级模拟。此技术对生产集群尤其有用。在这里，重要的是要尽量减少停机时间，并在升级完成后立即让升级后的集群准备就绪。

使用以下步骤：

1. 创建原始集群的克隆。按照[克隆 Amazon Aurora 数据库集群卷](Aurora.Managing.Clone.md)中过程操作。

1. 设置与原始集群中类似的写入器和读取器数据库实例集。

1. 对克隆的集群执行就地升级。按照[如何执行就地升级](AuroraMySQL.Upgrading.Procedure.md)中过程操作。

   创建克隆后立即开始升级。这样，集群卷仍然与原始集群的状态相同。如果克隆在升级之前处于空闲状态，则 Aurora 会在后台执行数据库清理过程。在这种情况下，克隆的升级并不是原始集群升级的准确模拟。

1. 使用克隆的集群测试应用程序兼容性、性能、管理过程等。

1. 如果遇到任何问题，请调整升级计划以解决这些问题。例如，调整任何应用程序代码以与更高版本的功能集兼容。根据集群中的数据量估计升级可能需要多长时间。您也可以选择将升级安排在集群不忙的时候。

1. 在您对应用程序和工作负载在测试集群中正常运行感到满意后，您可以为生产集群执行就地升级。

1. 努力显著减少集群在主要版本升级期间的总停机时间。为此，请确保升级时集群上的工作负载较低或为零。特别是确保在启动升级时没有长期运行的事务在进行。

### 蓝绿部署


在某些情况下，您的首要任务是立即从旧集群切换到升级后的集群。在此类情况下，您可以使用多步骤流程，并排运行新旧集群。此处，您可以将数据从旧集群复制到新集群，直到您准备好接管新集群。有关详细信息，请参阅[使用 Amazon Aurora 蓝绿部署进行数据库更新](blue-green-deployments.md)。

# Aurora MySQL 的主要版本升级预检查


将 MySQL 从一个主要版本升级到另一个主要版本，例如从 MySQL 5.7 升级到 MySQL 8.0，需要进行一些重大的架构更改，这要求进行仔细的规划和准备。与次要版本升级（重点主要是更新数据库引擎软件，在某些情况下还包括系统表）不同，主要 MySQL 升级通常会对数据库存储和管理其元数据的方式进行根本性的更改。

为协助您确定此类不兼容性，当从 Aurora MySQL 版本 2 升级到版本 3 时，Aurora 会自动运行升级兼容性检查（预检查），来检查数据库集群中的对象并确定可能阻碍升级继续进行的已知不兼容性。有关 Aurora MySQL 预检查的详细信息，请参阅 [Aurora MySQL 的预检查描述参考](AuroraMySQL.upgrade-prechecks.descriptions.md)。除了社区 MySQL [upgrade checker utility](https://dev.mysql.com/doc/mysql-shell/8.0/en/mysql-shell-utilities-upgrade.html) 运行的预检查之外，还会运行 Aurora 预检查。

这些预检查是必需的。您不能选择跳过它们。预检查提供以下好处：
+ 它们可以减少遇到升级失败的可能性，而升级失败可能导致停机时间延长。
+ 如果存在不一致性，Amazon Aurora 将阻止继续升级，并提供日志以供您参阅。然后，您可以使用日志，通过解决不一致性来准备数据库以升级到版本 3。有关解决不兼容性的详细信息，请参阅 MySQL 文档中的 [Preparing your installation for upgrade](https://dev.mysql.com/doc/refman/8.0/en/upgrade-prerequisites.html) 和 MySQL Server 博客上的 [Upgrading to MySQL 8.0? Here is what you need to know...](https://dev.mysql.com/blog-archive/upgrading-to-mysql-8-0-here-is-what-you-need-to-know/)。

  有关升级到 MySQL 8.0 的更多信息，请参阅 MySQL 文档中的[升级 MySQL](https://dev.mysql.com/doc/refman/8.0/en/upgrading.html)。

预检查在数据库集群变为脱机状态来进行主版本升级之前运行。如果预检查发现不兼容问题，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)
+ [

## 社区 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 的预检查过程


如前所述，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 | 
| --- | --- | --- | 
|  Started  |  正在进行升级准备：正在启动在线升级预检查。  | 无 | 
|  失败  |  数据库集群处于无法升级的状态：升级预检查失败。有关更多详细信息，请参阅 upgrade-prechecks.log 文件。 有关排查升级失败原因的更多信息，请参阅 [https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/AuroraMySQL.Upgrading.Troubleshooting.html](https://docs.amazonaws.cn/AmazonRDS/latest/AuroraUserGuide/AuroraMySQL.Upgrading.Troubleshooting.html)  |  查看 `upgrade-prechecks.log` 是否有错误。 纠正错误。 重试升级。  | 
|  成功  |  正在进行升级准备：已完成在线升级预检查。  |  预检查成功，未返回任何错误。 查看 `upgrade-prechecks.log` 是否有警告和通知。  | 

有关查看事件的更多信息，请参阅[查看 Amazon RDS 事件](USER_ListEvents.md)。

## Aurora MySQL 的预检查日志格式


升级兼容性检查（预检查）完成后，可以查看 `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 的预检查日志输出示例


下面的示例显示了您可能看到的预检查日志输出。有关运行的预检查的详细信息，请参阅 [Aurora MySQL 的预检查描述参考](AuroraMySQL.upgrade-prechecks.descriptions.md)。

**预检查状态为 OK，未检测到不兼容性**  
预检查查询成功完成。未检测到任何不兼容性。  

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

**预检查状态为 OK，检测到错误**  
预检查查询成功完成。检测到一个错误。  

```
{
  "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`;"
      },
 }
```

**预检查状态为 OK，检测到警告**  
当预检查成功或失败时，可能会返回警告。  
此处预检查查询成功完成。检测到两个警告。  

```
{
  "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"
      }
    ]
}
```

**预检查状态为 ERROR，未报告任何不兼容性**  
预检查查询失败，出现一个错误，因此无法验证不兼容性。  

```
{
  "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 版本的信息，以及位于预检查输出末尾的错误、警告和通知计数摘要。  
例如，以下输出显示有人尝试从 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 的性能


兼容性预检查在数据库实例进入脱机状态来进行升级之前运行，因此在正常情况下，它们不会在运行时导致数据库实例停机。但是，它们可能会影响写入器数据库实例上运行的应用程序工作负载。预检查通过 [information\$1schema](https://dev.mysql.com/doc/mysql-infoschema-excerpt/5.7/en/information-schema-introduction.html) 表访问数据字典，如果数据库对象很多，这可能会很慢。请考虑以下因素：
+ 预检查持续时间因数据库对象（例如表、列、例程和约束）的数量而异。包含大量对象的数据库集群可能需要更长的时间来运行预检查。

  例如，[removedFunctionsCheck](AuroraMySQL.upgrade-prechecks.descriptions.md#removedFunctionsCheck) 可能需要更长的时间，并且会根据 [stored objects](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)。

## 社区 MySQL 升级预检查摘要


以下是 MySQL 5.7 和 8.0 之间不兼容性的一般列表：
+ 与 MySQL 5.7 兼容的数据库集群不得使用 MySQL 8.0 不支持的功能。

  有关更多信息，请参阅 MySQL 文档中的 [MySQL 8.0 中删除的功能](https://dev.mysql.com/doc/refman/8.0/en/mysql-nutshell.html#mysql-nutshell-removals)。
+ 不得出现关键字或保留关键字违规情况。MySQL 8.0 中可能会保留一些以前未保留的关键字。

  有关更多信息，请参阅 MySQL 文档中的[关键字和保留关键字](https://dev.mysql.com/doc/refman/8.0/en/keywords.html)。
+ 要获得改进的 Unicode 支持，请考虑将使用 `utf8mb3` 字符集的对象转换为使用 `utf8mb4` 字符集。`utf8mb3` 字符集已弃用。此外，请考虑对字符集引用使用 `utf8mb4` 而不是 `utf8`，因为 `utf8` 当前是 `utf8mb3` 字符集的别名。

  有关更多信息，请参阅 MySQL 文档中的 [utf8mb3 字符集（3 字节 UTF-8 Unicode 编码）](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 模式。
+ 不得有包含长度超过 255 个字符的单个 `ENUM` 或 `SET` 列元素的表或存储过程。
+ 不得有驻留在共享 InnoDB 表空间中的表分区。
+ 表空间数据文件路径中不得有循环引用。
+ 不得有对 `GROUP BY` 子句使用 `ASC` 或 `DESC` 限定符的查询和存储程序定义。
+ 不得有任何已移除的系统变量，并且系统变量必须使用适用于 MySQL 8.0 的新默认值。
+ 不得有零（`0`）日期、日期时间或时间戳值。
+ 不得有由于文件移除或损坏而导致的架构不一致。
+ 不得有包含 `FTS` 字符串的表名称。
+ 不得有属于不同引擎的 InnoDB 表。
+ 不得有对于 MySQL 5.7 无效的表或架构名称。

有关运行的预检查的详细信息，请参阅 [Aurora MySQL 的预检查描述参考](AuroraMySQL.upgrade-prechecks.descriptions.md)。

有关升级到 MySQL 8.0 的更多信息，请参阅 MySQL 文档中的[升级 MySQL](https://dev.mysql.com/doc/refman/8.0/en/upgrading.html)。有关 MySQL 8.0 中变化的一般描述，请参阅 MySQL 文档中的 [What is new in MySQL 8.0](https://dev.mysql.com/doc/refman/8.0/en/mysql-nutshell.html)。

## Aurora MySQL 升级预检查摘要


Aurora MySQL 在从版本 2 升级到版本 3 时有自己的特定要求，包括以下各项：
+ 视图、例程、触发器和事件中不得有弃用的 SQL 语法，例如 `SQL_CACHE`、`SQL_NO_CACHE` 和 `QUERY_CACHE`。
+ 没有 `FTS` 索引的任何表上都不得有 `FTS_DOC_ID` 列。
+ InnoDB 数据字典和实际表定义之间不得有列定义不匹配。
+ 将 `lower_case_table_names` 参数设置为 `1` 时，所有数据库和表名都必须为小写。
+ 事件和触发器不得有缺失的或空的定义程序或无效的创建上下文。
+ 数据库中的所有触发器名称都必须是唯一的。
+ Aurora MySQL 版本 3 不支持 DDL 恢复和快速 DDL。数据库中不得有与这些功能相关的构件。
+ 采用 `REDUNDANT` 或 `COMPACT` 行格式的表的索引不能大于 767 字节。
+ 在 `tiny` 文本列上定义的索引的前缀长度不能超过 255 字节。对于 `utf8mb4` 字符集，这会将支持的前缀长度限制为 63 个字符。

  在 MySQL 5.7 中，使用 `innodb_large_prefix` 参数可支持更大的前缀长度。MySQL 8.0 中已弃用此参数。
+ `mysql.host` 表中不得有 InnoDB 元数据不一致。
+ 系统表中不得有列数据类型不匹配。
+ 不得有 XA 事务处于 `prepared` 状态。
+ 视图中的列名称不能超过 64 个字符。
+ 存储过程中的特殊字符不能不一致。
+ 表不能有数据文件路径不一致。

有关运行的预检查的详细信息，请参阅 [Aurora MySQL 的预检查描述参考](AuroraMySQL.upgrade-prechecks.descriptions.md)。

# Aurora MySQL 的预检查描述参考


此处详细描述了 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)

## 错误


以下预检查失败时会生成错误，升级无法继续。

**Topics**
+ [

### 报告错误的 MySQL 预检查
](#precheck-descriptions-errors.mysql)
+ [

### 报告错误的 Aurora MySQL 预检查
](#precheck-descriptions-errors.aurora)

### 报告错误的 MySQL 预检查


以下预检查来自社区 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**  
**预检查级别：错误**  
**`check table x for upgrade` 命令针对 `mysql` 架构报告的问题**  
在开始升级到 Aurora MySQL 版本 3 之前，将对数据库实例的 `mysql` 架构中的每个表运行 `check table for upgrade`。`check table for upgrade` 命令检查表中是否存在升级到较新 MySQL 版本期间可能出现的任何潜在问题。在尝试升级之前运行此命令，有助于提前确定和解决任何不兼容性，从而使实际升级过程更加顺畅。  
此命令对每个表执行各种检查，例如：  
+ 验证表结构和元数据是否与目标 MySQL 版本兼容
+ 检查表是否使用了任何已弃用或已移除的功能
+ 确保表可以正确地升级而不会丢失数据
有关更多信息，请参阅 MySQL 文档中的 [CHECK TABLE statement](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` 会执行多项检查。  
如果您在此项预检查中遇到任何错误，请向 [Amazon Support](https://www.amazonaws.cn/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 tablespace](https://dev.mysql.com/doc/refman/8.0/en/innodb-file-per-table-tablespaces.html) 来重建表。对所有表空间和表定义使用默认文件路径。  
Aurora MySQL 不支持一般表空间或 `CREATE TABLESPACE` 命令。  
在重建表空间之前，请参阅 MySQL 文档中的 [Online DDL operations](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`、`TEXT`、`GEOMETRY` 和 `JSON` 列不能有 [default values](https://dev.mysql.com/doc/refman/5.7/en/data-type-defaults.html)。在升级到 Aurora MySQL 版本 3 之前，请移除这些列上的所有默认子句。有关这些数据类型的默认处理方式的变化的更多信息，请参阅 MySQL 文档中的 [Data type default values](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`、`TEXT`、`GEOMETRY` 或 `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 文档中的 [Online DDL operations](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 移除了 [query cache](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 中的表元数据是否一致。  
如果您在此项预检查中遇到任何错误，请向 [Amazon Support](https://www.amazonaws.cn/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 之前，最大组合长度为 64 K，但 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 documentation](https://dev.mysql.com/doc/refman/8.0/en/identifier-length.html) 中所述。由于发现了外键长度可能等于或超过该值的 [issues](https://bugs.mysql.com/bug.php?id=88118)，导致升级失败，因此实施了这项预检查。如果您在此项预检查中遇到错误，则应 [alter or rename](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 文档中的 [Identifier case sensitivity](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` [event](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 文档中的 [Stored object access control](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 表定义之间的列定义是否匹配。如果检测到不匹配，则升级将无法继续。  
如果您在此项预检查中遇到任何错误，请向 [Amazon Support](https://www.amazonaws.cn/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 文档中的 [Stored object access control](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` 设置的值将用于该数据库的生命周期。此限制是作为 [Atomic Data Dictionary](https://dev.mysql.com/doc/refman/8.0/en/data-dictionary-file-removal.html) 实现的一部分而实施的，其中数据库对象从基于文件的元数据迁移到 `mysql` 架构中的内部 InnoDB 表。  
有关更多信息，请参阅 MySQL 文档中的 [Data dictionary changes](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 中 [case sensitivity](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 changes](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)
```
重新创建例程和触发器以使用正确的标识符语法和转义后，预检查通过，升级就可以继续了。有关标识符的更多信息，请参阅 MySQL 文档中的 [Schema object names](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 release notes](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 row formats](https://dev.mysql.com/doc/refman/5.7/en/innodb-row-format.html) 和 [InnoDB file-format management](https://dev.mysql.com/doc/refman/5.7/en/innodb-file-format.html)。  
在重建表空间之前，请参阅 MySQL 文档中的 [Online DDL operations](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 version](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 中引入的新 [Atomic Data Dictionary](https://dev.mysql.com/doc/refman/8.0/en/data-dictionary-file-removal.html) 将所有元数据存储在 `mysql` 架构的一组内部 InnoDB 表中。在升级期间，将在 `mysql` 架构中创建新的 [internal data dictionary tables](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 documentation](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。要修复此问题，在继续升级之前，必须 [rebuild](https://dev.mysql.com/doc/refman/5.7/en/rebuilding-tables.html) 包含此类旧时间数据类型的所有表。  
有关在 MySQL 5.7 中弃用旧的时间数据类型的更多信息，请参阅此 [blog](https://dev.mysql.com/blog-archive/how-to-easily-identify-tables-with-temporal-types-in-old-format/)。有关在 MySQL 8.0 中移除旧的时间数据类型的更多信息，请参阅此 [blog](https://dev.mysql.com/blog-archive/mysql-8-0-removing-support-for-old-temporal-datatypes/)。  
在重建表空间之前，请参阅 MySQL 文档中的 [Online DDL operations](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"
      }
  ]
},
```
表 `test.55_temporal_table` 中的 `timestamp_column` 列报告了一个错误，因为它使用了不再支持的旧时间磁盘存储格式。  
要解决此问题并让升级继续进行，请重建表，来将旧时间磁盘存储格式转换为 MySQL 5.6 中引入的新格式。有关在执行此操作之前的更多信息和先决条件，请参阅 MySQL 文档中的 [Converting between 3-byte and 4-byte Unicode character sets](https://dev.mysql.com/doc/refman/8.0/en/charset-unicode-conversion.html)。  
运行以下命令来重建此项预检查中提到的表，可将旧的时间类型转换为具有小数秒精度的较新格式。  

```
ALTER TABLE ... ENGINE=InnoDB;
```
有关重建表的更多信息，请参阅 MySQL 文档中的 [ALTER TABLE statement](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 文档中的 [Partitioning operations](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` 表，将违规分区 `p1` 放在 file-per-table 表空间中。  

```
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 中，已移除了许多内置函数。此项预检查会检查数据库中是否存在可能使用这些函数的对象。如果找到此类对象，则将返回错误。在重试升级之前，必须先解决这些问题。  
移除的大多数函数是 [spatial functions](https://dev.mysql.com/doc/refman/5.7/en/gis-wkt-functions.html)，这些函数已被等效的 `ST_*` 函数所取代。在这些情况下，可以修改数据库对象来使用新的过程命名。有关更多信息，请参阅 MySQL 文档中的 [MySQL 8.0 中删除的功能](https://dev.mysql.com/doc/refman/8.0/en/mysql-nutshell.html#mysql-nutshell-removals)。  
**输出示例：**  

```
{
  "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 引入了以前未保留的 [reserved keywords](https://dev.mysql.com/doc/mysqld-version-reference/en/keywords-8-0.html#keywords-new-in-8-0)。升级预检查工具将评估保留关键字在数据库对象名称及其定义和正文中的使用情况。如果它检测到数据库对象（例如存储过程、函数、事件和触发器）中正在使用保留关键字，则升级将失败并向 `upgrade-prechecks.log` 文件中发布一个错误。要解决此问题，必须在升级之前，更新这些对象定义并将所有此类引用括在单引号（'）中。有关在 MySQL 中对保留字进行转义的更多信息，请参阅 MySQL 文档中的 [String literals](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 引入了 [Atomic Data Dictionary](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` 预检查，来确保所有数据字典元数据对象都处于同步状态。如果检测到任何孤立的元数据对象，则升级不会继续。要继续升级，请清理这些孤立的元数据对象。  
如果您在此项预检查中遇到任何错误，请向 [Amazon Support](https://www.amazonaws.cn/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 预检查


以下预检查特定于 Aurora MySQL：
+ [auroraCheckDDLRecovery](#auroraCheckDDLRecovery)
+ [auroraCheckRdsUpgradePrechecksTable](#auroraCheckRdsUpgradePrechecksTable)
+ [auroraFODUpgradeCheck](#auroraFODUpgradeCheck)
+ [auroraGetDanglingFulltextIndex](#auroraGetDanglingFulltextIndex)
+ [auroraUpgradeCheckForDatafilePathInconsistency](#auroraUpgradeCheckForDatafilePathInconsistency)
+ [auroraUpgradeCheckForFtsSpaceIdZero](#auroraUpgradeCheckForFtsSpaceIdZero)
+ [auroraUpgradeCheckForIncompleteXATransactions](#auroraUpgradeCheckForIncompleteXATransactions)
+ [auroraUpgradeCheckForInstanceLimit](#auroraUpgradeCheckForInstanceLimit)
+ [auroraUpgradeCheckForInternalUsers](#auroraUpgradeCheckForInternalUsers)
+ [auroraUpgradeCheckForMasterUser](#auroraUpgradeCheckForMasterUser)
+ [auroraUpgradeCheckForPrefixIndexOnGeometryColumns](#auroraUpgradeCheckForPrefixIndexOnGeometryColumns)
+ [auroraUpgradeCheckForSpecialCharactersInProcedures](#auroraUpgradeCheckForSpecialCharactersInProcedures)
+ [auroraUpgradeCheckForSysSchemaObjectTypeMismatch](#auroraUpgradeCheckForSysSchemaObjectTypeMismatch)
+ [auroraUpgradeCheckForViewColumnNameLength](#auroraUpgradeCheckForViewColumnNameLength)
+ [auroraUpgradeCheckIndexLengthLimitOnTinyColumns](#auroraUpgradeCheckIndexLengthLimitOnTinyColumns)
+ [auroraUpgradeCheckMissingInnodbMetadataForMysqlHostTable](#auroraUpgradeCheckMissingInnodbMetadataForMysqlHostTable)
+ [auroraUpgradeCheckForInvalidUtf8mb3ColumnComments](#auroraUpgradeCheckForInvalidUtf8mb3ColumnComments)

**auroraCheckDDLRecovery**  
**预检查级别：错误**  
**检查是否存在与 Aurora DDL 恢复功能相关的构件**  
作为 Aurora MySQL 中数据定义语言（DDL）恢复实现的一部分，正在运行的 DDL 语句的元数据保留在 `mysql` 架构内的 `ddl_log_md_table` 和 `ddl_log_table` 表中。Aurora 对于 DDL 恢复的实现在版本 3 及后续版本中不受支持，因为该功能是 MySQL 8.0 中新的 [Atomic Data Dictionary](https://dev.mysql.com/doc/refman/8.0/en/data-dictionary-file-removal.html) 实现的一部分。如果在兼容性检查期间有任何 DDL 语句正在运行，则此项预检查可能会失败。我们建议您在没有任何 DDL 语句正在运行的情况下尝试升级。  
如果在没有任何 DDL 语句正在运行的情况下，此项预检查失败，请向 [Amazon Support](https://www.amazonaws.cn/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 服务执行的仅限内部的预检查。任何错误都将在升级时自动得以处理，可以安全地忽略。  
如果您在此项预检查中遇到任何错误，请向 [Amazon Support](https://www.amazonaws.cn/support) 提交案例，来请求解决元数据不一致性。或者，可以通过执行逻辑转储，然后还原到新的 Aurora MySQL 版本 3 数据库集群来重试升级。  

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

**auroraFODUpgradeCheck**  
**预检查级别：错误**  
**检查是否存在与 Aurora 快速 DDL 功能相关的构件**  
Aurora MySQL 版本 2 在[实验室模式](AuroraMySQL.Updates.LabMode.md)下引入了[快速 DDL](AuroraMySQL.Managing.FastDDL.md) 优化，来提高某些 DDL 操作的效率。在 Aurora MySQL 版本 3 中，实验室模式已被移除，快速 DDL 实现已被名为 [Instant 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 文档中的 [Online DDL operations](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` 列可能会变成孤立的列。有关更多信息，请参阅 [Bug \$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 中，当您向 InnoDB 表添加 [full-text index](https://dev.mysql.com/doc/refman/5.7/en/innodb-fulltext-index.html) 时，会创建许多辅助索引表空间。由于 MySQL 的早期版本中存在一个 [bug](https://bugs.mysql.com/bug.php?id=72132)（在 5.6.20 版本中已修复），这些辅助索引表可能是在 [system tablespace](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 文档中的 [Partitioning operations](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 数据库实例执行 [clean shutdown](https://dev.mysql.com/doc/refman/5.7/en/glossary.html#glos_slow_shutdown)。这可以确保所有事务都已提交或回滚，并且 InnoDB 已清除所有撤消日志记录。由于事务回滚是必需的，因此，如果数据库中有任何 [XA transactions](https://dev.mysql.com/doc/refman/5.7/en/xa.html) 处于已准备状态，则可能会阻止继续进行干净关闭。因此，如果检测到任何已准备的 XA 事务，则在您采取措施来提交或回滚这些事务之前，升级将无法继续。  
有关使用 `XA RECOVER` 查找处于已准备状态的 XA 事务的更多信息，请参阅 MySQL 文档中的 [XA transaction SQL statements](https://dev.mysql.com/doc/refman/5.7/en/xa-statements.html)。有关 XA 事务状态的更多信息，请参阅 MySQL 文档中的 [XA transaction states](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 documentation](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**  
**预检查级别：错误**  
**检查当前实例类是否支持升级**  
目前不支持从 Aurora MySQL 版本 2.12.0 或 2.12.1（其中写入器[数据库实例类](Concepts.DBInstanceClass.md)为 db.r6i.32xlarge）运行就地升级。在这种情况下，预检查会返回错误。要让升级继续进行，可以将数据库实例类更改为 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": []
}
```

**auroraUpgradeCheckForMasterUser**  
**预检查级别：错误**  
**检查 RDS 主用户是否存在**  
MySQL 8 添加了支持 [role](https://dev.mysql.com/doc/refman/8.0/en/roles.html) 和 [dynamic privileges](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 '%'"
      }
  ]
}
```
重置主用户密码后，预检查将通过，可以重试升级。  
以下示例使用 Amazon 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) 开始，无法再使用 [GEOMETRY](https://dev.mysql.com/doc/refman/5.7/en/gis-data-formats.html) 数据类型在列上创建 [prefixed](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` 架构中的新的内部数据字典表中，以支持新实现的 [Atomic Data Dictionary](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."
      }
  ]
}
```
预检查报告数据库集群在 `test` 数据库包含一个名为 `get_version_proc` 的过程，该过程在过程主体中包含特殊字符。  
删除并重新创建该存储过程后，预检查成功，并支持升级继续进行。  

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

**auroraUpgradeCheckForSysSchemaObjectTypeMismatch**  
**预检查级别：错误**  
**检查 `sys` 架构的对象类型不匹配**  
[sys schema](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)
```
要解决这个问题，可以删除该视图并使用 [correct definition](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 中的 [maximum permitted length of a column name](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 中使用 [binary data type](https://dev.mysql.com/doc/refman/5.7/en/binary-varbinary.html) 对某个列创建索引时，必须在索引定义中添加 [prefix](https://dev.mysql.com/doc/refman/5.7/en/column-indexes.html#column-indexes-prefix) 长度。在 MySQL 8.0 之前，在某些情况下，可以指定比此类数据类型支持的最大大小更大的前缀长度。例如 `TINYTEXT` 和 `TINYBLOB` 列，其中允许的最大数据大小为 255 字节，但允许使用大于此值的索引前缀。有关更多信息，请参阅 MySQL 文档中的 [InnoDB limits](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 服务执行的仅限内部的预检查。任何错误都将在升级时自动得以处理，可以安全地忽略。  
如果您在此项预检查中遇到任何错误，请向 [Amazon Support](https://www.amazonaws.cn/support) 提交案例，来请求解决元数据不一致性。或者，可以通过执行逻辑转储，然后还原到新的 Aurora MySQL 版本 3 数据库集群来重试升级。

**auroraUpgradeCheckForInvalidUtf8mb3ColumnComments**  
**预检查级别：错误**  
**检查是否存在无效的 utf8mb3 列注释**  
此项预检查识别出的表所包含的列注释具有无效的 utf8mb3 字符编码。在 MySQL 8.0 中，对元数据（包括列注释）中的字符编码应用了更严格的验证。如果任何列注释包含在 utf8mb3 字符集中无效的字符，则升级将失败。  
此问题最常见的原因是列注释中存在非 BMP（基本多语言平面）字符。非 BMP 字符需要 4 字节的 UTF-8 编码（utf8mb4），但 utf8mb3 仅支持 3 字节序列，而无法表示这些字符。  
要解决此问题，在尝试升级之前，必须修改列注释以移除或替换任何非 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 支持。

## 警告


以下预检查失败时会生成警告，但升级可以继续。

**Topics**
+ [

### 报告警告的 MySQL 预检查
](#precheck-descriptions-warnings.mysql)
+ [

### 报告警告的 Aurora MySQL 预检查
](#precheck-descriptions-warnings.aurora)

### 报告警告的 MySQL 预检查


以下预检查来自社区 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 compatibility issues and solutions](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 中，[removed](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 documentation](https://dev.mysql.com/doc/refman/5.7/en/create-procedure.html)，MySQL 存储在创建或更改例程时生效的 `sql_mode` 设置。它始终使用此设置运行例程，而不管例程启动时 `sql_mode` 设置如何。  
在更改 `sql_mode` 之前，请参阅 MySQL 文档中的 [Server SQL modes](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"
      }
  ]
}
```
此警告让您了解可能需要查看一些应用程序查询。如果应用程序查询未正确地 [escaping string literals](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 文档中的 [Converting between 3-byte and 4-byte Unicode character sets](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 文档中的 [Converting between 3-byte and 4-byte Unicode character sets](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 预检查


以下预检查特定于 Aurora MySQL：
+ [auroraUpgradeCheckForRollbackSegmentHistoryLength](#auroraUpgradeCheckForRollbackSegmentHistoryLength)
+ [auroraUpgradeCheckForUncommittedRowModifications](#auroraUpgradeCheckForUncommittedRowModifications)

**auroraUpgradeCheckForRollbackSegmentHistoryLength**  
**预检查级别：警告**  
**检查集群的回滚段历史记录列表长度是否很高**  
如在 [auroraUpgradeCheckForIncompleteXATransactions](#auroraUpgradeCheckForIncompleteXATransactions) 中所提到的那样，在运行主要版本升级过程时，务必对 Aurora MySQL 版本 2 数据库实例执行 [clean shutdown](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."
      }
  ]
}
```
预检查返回警告，因为它检测到数据库集群上的 InnoDB 撤消 HLL 很高（82989114）。尽管升级继续进行，但根据要清除的撤消量，可能会延长升级过程中所需的停机时间。  
我们建议您在生产环境中运行升级之前，先[调查数据库集群上的未结事务](proactive-insights.history-list.md)，以确保 HLL 保持为可管理的大小。

**auroraUpgradeCheckForUncommittedRowModifications**  
**预检查级别：警告**  
**检查是否有许多未提交的行修改**  
如在 [auroraUpgradeCheckForIncompleteXATransactions](#auroraUpgradeCheckForIncompleteXATransactions) 中所提到的那样，在运行主要版本升级过程时，务必对 Aurora MySQL 版本 2 数据库实例执行 [clean shutdown](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."
      }
  ]
},
```
预检查报告称，数据库集群包含一个事务，其中有 11000000 个未提交的行更改将需要在干净关闭过程中回滚。升级将继续进行，但为了减少升级过程中的停机时间，建议您在生产集群上运行升级之前对此进行监控和调查。  
要查看写入器数据库实例上的活动事务，可以使用 [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 文档中的 [Optimizing InnoDB transaction management](https://dev.mysql.com/doc/refman/5.7/en/optimizing-innodb-transaction-management.html)。

## 版权声明


以下预检查失败时会生成通知，但升级可以继续。

**sqlModeFlagCheck**  
**预检查级别：通知**  
**使用过时的 `sql_mode` 标志**  
除了 `MAXDB` 外，还 [removed](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 documentation](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)。

## 错误、警告或通知


根据预检查输出，以下预检查可能会返回错误、警告或通知。

**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 statement](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` 外键约束缺少索引或数据类型不匹配。有关 [foreign key constraints](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 文档中的 [Checking version compatibility](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": []
},
```

# 如何执行就地升级


我们建议您查看 [Aurora MySQL 主要版本就地升级的工作原理](AuroraMySQL.Updates.MajorVersionUpgrade.md#AuroraMySQL.Upgrading.Sequence)中的背景材料。

按[为 Aurora MySQL 集群计划主要版本升级](AuroraMySQL.Updates.MajorVersionUpgrade.md#AuroraMySQL.Upgrading.Planning)中所述执行任何升级前的计划和测试。

## 控制台


以下示例将 `mydbcluster-cluster` 数据库集群升级到 Aurora MySQL 版本 3.04.1。

**要升级 Aurora MySQL 数据库集群的主要版本**

1. 登录 Amazon Web Services 管理控制台 并通过以下网址打开 Amazon RDS 控制台：[https://console.aws.amazon.com/rds/](https://console.amazonaws.cn/rds/)。

1. 如果您将自定义参数组用于原始数据库集群，请创建与新的主要版本兼容的相应参数组。对这个新参数组中的配置参数进行任何必要的调整。有关更多信息，请参阅“[就地升级如何影响集群的参数组](#AuroraMySQL.Upgrading.ParamGroups)”。

1.  在导航窗格中，选择 **Databases (数据库)**。

1.  在列表中，选择您要修改的数据库集群。

1.  选择 **Modify (修改)**。

1.  对于 **Version**（版本），选择新的 Aurora MySQL 主要版本。

   我们通常建议使用主要版本的最新次要版本。在这里，我们选择当前的默认版本。  
![\[Aurora MySQL 数据库集群从版本 2 就地升级到版本 3\]](http://docs.amazonaws.cn/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 创建的手动快照。

## Amazon CLI


要升级 Aurora MySQL 数据库集群的主要版本，请结合使用 Amazon CLI [modify-db-cluster](https://docs.amazonaws.cn/cli/latest/reference/rds/modify-db-cluster.html) 命令与以下所需的参数：
+ `--db-cluster-identifier`
+ `--engine-version`
+ `--allow-major-version-upgrade`
+  `--apply-immediately` 或者 `--no-apply-immediately`

如果您的集群使用任何自定义参数组，则还要包含以下一个或两个选项：
+ `--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.amazonaws.cn/cli/latest/reference/rds/modify-global-cluster.html) 命令操作而不是 `modify-db-cluster`。有关更多信息，请参阅“[全局数据库的就地主要版本升级](#AuroraMySQL.Upgrading.GlobalDB)”。

## RDS API


要升级 Aurora MySQL 数据库集群的主要版本，请结合使用 RDS API 操作 [ModifyDBCluster](https://docs.amazonaws.cn/AmazonRDS/latest/APIReference/API_ModifyDBCluster.html) 与以下所需的参数：
+ `DBClusterIdentifier`
+ `Engine`
+ `EngineVersion`
+ `AllowMajorVersionUpgrade`
+ `ApplyImmediately`（设置为 `true` 或 `false`）

**注意**  
如果您的集群属于 Aurora 全局数据库的一部分，则就地升级程序会略有不同。您将调用 [ModifyGlobalCluster](https://docs.amazonaws.cn/AmazonRDS/latest/APIReference/API_ModifyGlobalClusterParameterGroup.html) 操作而不是 `ModifyDBCluster`。有关更多信息，请参阅“[全局数据库的就地主要版本升级](#AuroraMySQL.Upgrading.GlobalDB)”。

## 就地升级如何影响集群的参数组


对于与 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 版本之间的集群属性更改


当从 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
```

## 全局数据库的就地主要版本升级


 对于 Aurora Global Database，您可升级全局数据库集群。Aurora 会同时自动升级所有集群，并确保所有集群运行相同的引擎版本。此要求是因为对系统表、数据文件格式等所做的任何更改都会自动复制到所有辅助集群。

按照[Aurora MySQL 主要版本就地升级的工作原理](AuroraMySQL.Updates.MajorVersionUpgrade.md#AuroraMySQL.Upgrading.Sequence)中的说明进行操作。指定要升级的内容时，请确保选择全局数据库集群，而不是其包含的集群之一。

如果您使用 Amazon Web Services 管理控制台，请选择具有角色 **Global database**（全局数据库）的项目。

![\[升级全局数据库集群\]](http://docs.amazonaws.cn/AmazonRDS/latest/AuroraUserGuide/images/aurora-global-databases-major-upgrade-global-cluster.png)


 如果您使用 Amazon CLI 或 RDS API，请通过调用 [modify-global-cluster](https://docs.amazonaws.cn/cli/latest/reference/rds/modify-global-cluster.html) 命令或 [ModifyGlobalCluster](https://docs.amazonaws.cn/AmazonRDS/latest/APIReference/API_ModifyGlobalCluster.html) 操作来启动升级过程。您可以使用其中一个操作来代替 `modify-db-cluster` 或 `ModifyDBCluster`。

**注意**  
在对该 Aurora 全局数据库执行主要版本升级时，无法为全局数据库集群指定自定义参数组。在全局集群的每个区域中创建自定义参数组。然后，在升级后手动将它们应用于区域集群。

 要使用 Amazon CLI 升级 Aurora MySQL 全局数据库集群的主要版本，请结合使用 [modify-global-cluster](https://docs.amazonaws.cn/cli/latest/reference/rds/modify-global-cluster.html) 命令与以下所需的参数：
+  `--global-cluster-identifier` 
+  `--engine aurora-mysql` 
+  `--engine-version` 
+  `--allow-major-version-upgrade` 

以下示例将全局数据库集群升级到 Aurora MySQL 版本 2.10.2。

**Example**  
对于 Linux、macOS 或 Unix：  

```
aws rds modify-global-cluster \
          --global-cluster-identifier global_cluster_identifier \
          --engine aurora-mysql \
          --engine-version 5.7.mysql_aurora.2.10.2 \
          --allow-major-version-upgrade
```
对于 Windows：  

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

## 回溯注意事项


如果您升级的集群启用了回溯功能，您无法将升级的集群回溯到升级之前的时间。

# Aurora MySQL 就地升级教程
Aurora MySQL 就地升级教程

以下 Linux 示例展示了如何使用 Amazon CLI 执行就地升级过程的一般步骤。

第一个示例创建了运行 Aurora MySQL 版本 2.x 的 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 版本和集群所在的 Amazon Web Services 区域。第一个命令（带 `--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 主要版本升级失败的原因
查找主要版本升级失败的原因

在[教程](AuroraMySQL.Upgrading.Tutorial.md)中，从 Aurora MySQL 版本 2 升级到版本 3 已获成功。但是，如果升级失败，您会想知道原因。

您可以首先使用 `describe-events` Amazon 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 就地升级的故障排除


可以使用以下提示帮助排查 Aurora MySQL 就地升级问题。这些提示不适用于 Aurora Serverless 数据库集群。


| 就地升级被取消或减慢的原因 | 效果 | 允许在维护时段内完成就地升级的解决方案 | 
| --- | --- | --- | 
| 尚未修补关联的 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.amazonaws.cn/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 version 2 (with MySQL 5.7 compatibility) to version 3 (with MySQL 8.0 compatibility) upgrade checklist, Part 1](https://www.amazonaws.cn/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 version 2 (with MySQL 5.7 compatibility) to version 3 (with MySQL 8.0 compatibility) upgrade checklist, Part 2](https://www.amazonaws.cn/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 的升级后清理


将任何 Aurora MySQL 版本 2 集群升级到 Aurora MySQL 版本 3 后，您可以执行以下其他清理操作：
+ 为任何自定义参数组创建与 MySQL 8.0 兼容的新版本。将所有必要的自定义参数值应用于新参数组。
+ 更新任何 CloudWatch 告警、设置脚本等，以便对名称受到包含性语言更改影响的任何指标使用新名称。有关此类指标的列表，请参阅 [Aurora MySQL 版本 3 的包容性语言更改](AuroraMySQL.Compare-v2-v3.md#AuroraMySQL.8.0-inclusive-language)。
+ 更新任何 Amazon CloudFormation 模板，以对名称受到包含性语言更改影响的任何配置参数使用新名称。有关此类参数的列表，请参阅 [Aurora MySQL 版本 3 的包容性语言更改](AuroraMySQL.Compare-v2-v3.md#AuroraMySQL.8.0-inclusive-language)。

## 空间索引


升级到 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)。