

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

# 將 Aurora MySQL 第 3 版升級至 8.4 版的預先檢查描述
<a name="AuroraMySQL.upgrade-prechecks-v3-to-v84.descriptions"></a>

當您從 Aurora MySQL 第 3 版 （與 MySQL 8.0 相容） 升級至 Aurora MySQL 第 8.4 版 （與 MySQL 8.4 相容） 時，會執行下列預先檢查。這些預先檢查會在升級開始之前識別潛在的相容性問題。

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

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

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

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

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

下列預先檢查來自 Community MySQL：
+ [deprecatedRouterAuthMethod](#v84-deprecatedRouterAuthMethod)
+ [partitionsWithPrefixKeys](#v84-partitionsWithPrefixKeys)
+ [columnDefinition](#v84-columnDefinition)

**deprecatedRouterAuthMethod**  
**預先檢查層級：錯誤**  
**檢查 MySQL Router 內部帳戶使用的已棄用或無效的身分驗證方法**  
此預先檢查會驗證 MySQL Router 內部帳戶未使用已在 MySQL 8.4 中移除或變更的已棄用或無效的身分驗證方法。當未指示 Router 使用現有帳戶時，MySQL Router 帳戶會在引導時間自動建立。  
**輸出範例：**  

```
{
  "id": "deprecatedRouterAuthMethod",
  "title": "Check for deprecated or invalid authentication methods in use by MySQL Router internal accounts.",
  "status": "OK",
  "description": "Warning: The following accounts are MySQL Router accounts that use a deprecated authentication method.\nThose accounts are automatically created at bootstrap time when the Router is not instructed to use an existing account. Please upgrade MySQL Router to the latest version to ensure deprecated authentication methods are no longer used.\nSince version 8.0.19 it's also possible to instruct MySQL Router to use a dedicated account. That account can be created using the AdminAPI.",
  "documentationLink": "https://dev.mysql.com/doc/mysql-shell/en/configuring-router-user.html https://dev.mysql.com/doc/mysql-router/en/mysqlrouter.html#option_mysqlrouter_account",
  "detectedProblems": [
      {
        "level": "Error",
        "dbObject": "mysql_router_test@%",
        "description": " - router user with deprecated authentication method."
      }
  ]
}
```
預先檢查會傳回錯誤，因為`mysql_router_test`帳戶正在使用已棄用的身分驗證方法，例如 `mysql_native_password`或 `sha256_password`。  
若要驗證使用中的身分驗證方法：  

```
SELECT user, host, plugin FROM mysql.user WHERE user = 'mysql_router_test';
```
**解決方法：**  
更新 MySQL Router 帳戶以使用`caching_sha2_password`身分驗證：  

```
ALTER USER 'mysql_router_test'@'%' IDENTIFIED WITH caching_sha2_password BY '{{new_password}}';
```
或者，將 MySQL Router 升級至最新版本，以確保已淘汰的身分驗證方法不再使用。從 8.0.19 版開始，您也可以指示 MySQL Router 使用使用 AdminAPI 建立的專用帳戶。

**partitionsWithPrefixKeys**  
**預先檢查層級：錯誤**  
**使用具有字首索引的資料欄，依索引鍵檢查分割區**  
此預先檢查會識別在其分割金鑰中使用具有字首索引鍵索引之資料欄的分割資料表。金鑰分割不支援資料欄字首上的索引 - 它們會被分割區函數忽略，並且自 MySQL 8.4.0 起不允許。  
如需詳細資訊，請參閱 MySQL 文件中的[分割的限制。](https://dev.mysql.com/doc/refman/en/partitioning-limitations.html)  
**輸出範例：**  

```
{
  "id": "partitionsWithPrefixKeys",
  "title": "Checks for partitions by key using columns with prefix key indexes",
  "status": "OK",
  "description": "Indexes on column prefixes are not supported for key partitioning, they are ignored by the partition function and so they are not allowed as of 8.4.0. This check identifies tables with partitions defined this way, they should be fixed before upgrading to 8.4.0.",
  "documentationLink": "https://dev.mysql.com/doc/refman/en/partitioning-limitations.html",
  "detectedProblems": [
      {
        "level": "Error",
        "dbObject": "test.test_partition_prefix",
        "description": "Error: the `test`.`test_partition_prefix` table uses partition by KEY using the following columns with prefix index: name."
      }
  ]
}
```
**解決方法：**  

```
-- Check for prefix indexes (Sub_part column shows prefix length)
SHOW INDEX FROM test.test_partition_prefix;

-- Option 1: Change partition to use non-prefix columns only
ALTER TABLE test.test_partition_prefix PARTITION BY KEY (id) PARTITIONS 4;

-- Option 2: Remove prefix from index
ALTER TABLE test.test_partition_prefix
  DROP PRIMARY KEY,
  ADD PRIMARY KEY (id, name);  -- Full column, no prefix

-- Option 3: Remove partitioning
ALTER TABLE test.test_partition_prefix REMOVE PARTITIONING;
```

**columnDefinition**  
**預先檢查層級：錯誤**  
**檢查資料欄定義中的錯誤**  
此預先檢查會驗證所有資料欄定義是否與 MySQL 8.4 要求相容。它會特別識別 類型 `FLOAT`或 的資料欄`DOUBLE`，並已設定`AUTO_INCREMENT`旗標，這在 MySQL 8.4 中不再受支援。  
**輸出範例：**  

```
{
  "id": "columnDefinition",
  "title": "Checks for errors in column definitions",
  "status": "OK",
  "description": "Identifies column definitions that may not be supported in future versions of MySQL",
  "detectedProblems": [
      {
        "level": "Error",
        "dbObject": "test.test_column_def.id",
        "description": "The column is of type FLOAT and has the AUTO_INCREMENT flag set, this is no longer supported."
      }
  ]
}
```
**解決方法：**  
將資料欄類型從 `FLOAT`或 `DOUBLE` 變更為整數類型：  

```
-- Check current definition
SHOW CREATE TABLE test.test_column_def\G

-- Change FLOAT AUTO_INCREMENT to BIGINT AUTO_INCREMENT
ALTER TABLE test.test_column_def MODIFY COLUMN id BIGINT NOT NULL AUTO_INCREMENT;

-- Verify
SHOW CREATE TABLE test.test_column_def\G
```

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

下列預先檢查專屬於 Aurora MySQL：
+ [auroraUnsupportedPluginsCheck](#v84-auroraUnsupportedPluginsCheck)
+ [auroraUnsupportedComponentsCheck](#v84-auroraUnsupportedComponentsCheck)
+ [auroraUpgradeCheckForSysSchemaObjectTypeMismatch](#v84-auroraUpgradeCheckForSysSchemaObjectTypeMismatch)

**auroraUnsupportedPluginsCheck**  
**預先檢查層級：錯誤**  
**檢查是否有不支援的外掛程式**  
此 Aurora 特定的預先檢查可識別 Aurora MySQL 8.4 版中不支援的外掛程式。Aurora 具有與社群 MySQL 不同的特定外掛程式相容性要求。  
**輸出範例：**  

```
{
  "id": "auroraUnsupportedPluginsCheck",
  "title": "Check for unsupported plugins",
  "status": "OK",
  "description": "Checks for unsupported plugins installed in the database",
  "documentationLink": "https://docs.aws.amazon.com/AmazonRDS/latest/AuroraMySQLReleaseNotes/",
  "detectedProblems": [
      {
        "level": "Error",
        "dbObject": "all",
        "description": "Plugin simple_parser loaded in the engine. To proceed with the upgrade, remove this plugin."
      }
  ]
}
```
**解決方法：**  
解除安裝不支援的外掛程式：  

```
UNINSTALL PLUGIN {{plugin_name}};
```

**auroraUnsupportedComponentsCheck**  
**預先檢查層級：錯誤**  
**檢查不支援的元件**  
此預先檢查會驗證目前沒有安裝或作用中 Aurora MySQL 8.4 版中不支援的 MySQL 元件。元件與外掛程式不同，並透過元件基礎設施提供延伸功能。  
**輸出範例：**  

```
{
  "id": "auroraUnsupportedComponentsCheck",
  "title": "Check for unsupported components",
  "status": "OK",
  "description": "Checks for unsupported components installed in the database",
  "documentationLink": "https://docs.aws.amazon.com/AmazonRDS/latest/AuroraMySQLReleaseNotes/",
  "detectedProblems": [
      {
        "level": "Error",
        "dbObject": "all",
        "description": "Component file://component_log_sink_json loaded in the engine. To proceed with the upgrade, uninstall this component."
      }
  ]
}
```
**解決方法：**  
解除安裝不支援的元件：  

```
UNINSTALL COMPONENT '{{component_name}}';
```

**auroraUpgradeCheckForSysSchemaObjectTypeMismatch**  
**預先檢查層級：錯誤**  
**檢查 sys 結構描述的物件類型不符**  
此預先檢查會驗證`sys`結構描述中的所有物件是否具有正確的物件類型和定義。sys 結構描述是一種系統結構描述，可提供資料庫監控和診斷的檢視和程序。如果手動修改或損毀結構描述，可能會發生不相符的情況。  
**輸出範例：**  

```
{
  "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.host_summary",
        "description": "Your object sys.host_summary has a type mismatch. To fix the inconsistency we recommend to rename or remove the object before upgrading (use RENAME TABLE command)."
      }
  ]
}
```
**解決方法：**  

```
-- Check the object type
SELECT TABLE_NAME, TABLE_TYPE FROM information_schema.tables
WHERE TABLE_SCHEMA = 'sys' AND TABLE_NAME = 'host_summary';

-- Option 1: Rename the mismatched object
RENAME TABLE sys.host_summary TO sys.host_summary_backup;

-- Option 2: Drop the mismatched object
DROP TABLE sys.host_summary;
```

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

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

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

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

下列預先檢查來自 Community MySQL：
+ [deprecatedDefaultAuth](#v84-deprecatedDefaultAuth)
+ [foreignKeyReferences](#v84-foreignKeyReferences)

**deprecatedDefaultAuth**  
**預先檢查層級：警告**  
**檢查系統變數中的已棄用或無效預設身分驗證方法**  
此預先檢查會驗證`default_authentication_plugin`系統變數未設定為已取代的身分驗證方法。  
MySQL 8.4.0 完全移除已棄用`default_authentication_plugin`的選項。`mysql_native_password` 外掛程式預設為自 MySQL 8.4.0 起停用，且在未來版本中可能會移除。
如需 8.4 版中身分驗證變更的詳細資訊，請參閱 [從 Aurora MySQL 第 3 版升級至第 8.4 版的安全性考量事項](AuroraMySQL.Upgrade-v3-v84-security.md)。  
**輸出範例：**  

```
{
  "id": "deprecatedDefaultAuth",
  "title": "Check for deprecated or invalid default authentication methods in system variables.",
  "status": "OK",
  "description": "The following variables have problems with their set authentication method:",
  "detectedProblems": [
      {
        "level": "Warning",
        "dbObject": "default_authentication_plugin",
        "description": "mysql_native_password authentication method is deprecated and it should be considered to correct this before upgrading to 8.4.0 release."
      },
      {
        "level": "Warning",
        "dbObject": "authentication_policy",
        "description": "mysql_native_password authentication method is deprecated and it should be considered to correct this before upgrading to 8.4.0 release."
      }
  ]
}
```
**解決方法：**  
更新身分驗證系統變數以使用 `caching_sha2_password`：  

1. 前往 Amazon RDS 主控台並導覽至**參數群組**。

1. 選取您的資料庫叢集參數群組。

1. 修改下列參數：
   + `default_authentication_plugin` = `caching_sha2_password`
   + `authentication_policy` = `caching_sha2_password,*,`

1. 套用變更。可能需要重新開機。
在進行此變更之前，請確定您的應用程式用戶端支援`caching_sha2_password`身分驗證。有些較舊的 MySQL 用戶端程式庫可能不支援此身分驗證方法。

**foreignKeyReferences**  
**預先檢查層級：警告**  
**檢查外部索引鍵是否未參考完整的唯一索引**  
此預先檢查可確保所有外部金鑰限制條件參考皆完整填寫唯一或主要金鑰索引。從 MySQL 8.4.0 開始，部分索引的外部索引鍵可能遭到禁止。  
**輸出範例：**  

```
{
  "id": "foreignKeyReferences",
  "title": "Checks for foreign keys not referencing a full unique index",
  "status": "OK",
  "description": "Foreign keys to partial indexes may be forbidden as of 8.4.0, this check identifies such cases to warn the user.",
  "detectedProblems": [
      {
        "level": "Warning",
        "dbObject": "sample.child_table_ibfk_1",
        "description": "invalid foreign key defined as 'child_table(parent_name)' references a non unique key at table 'parent_table'."
      }
  ]
}
```
**解決方法：**  
選擇最適合您應用程式的選項：  

```
-- Option 1: Add unique index on parent table (if values are unique)
ALTER TABLE test.parent_table ADD UNIQUE INDEX idx_parent_name_unique (parent_name);

-- Option 2: Drop the foreign key if not needed
ALTER TABLE test.child_table DROP FOREIGN KEY child_table_ibfk_1;
```

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

下列預先檢查專屬於 Aurora MySQL：
+ [auroraValidatePasswordPluginCheck](#v84-auroraValidatePasswordPluginCheck)

**auroraValidatePasswordPluginCheck**  
**預先檢查層級：警告**  
**檢查是否已棄用 validate\_password 外掛程式**  
此預先檢查可識別已棄用`validate_password`外掛程式的使用情況。在 MySQL 8.0\+ 中，已將 validate\_password 功能重新實作為元件 (`component_validate_password`)。Aurora MySQL 8.4 版需要遷移至元件型實作。  
如需詳細資訊，請參閱[密碼驗證元件遷移](AuroraMySQL.Upgrade-v3-v84-security.md#AuroraMySQL.Upgrade-v3-v84-security.validate-password)。  
**輸出範例：**  

```
{
  "id": "auroraValidatePasswordPluginCheck",
  "title": "Check for deprecated validate_password plugin",
  "status": "OK",
  "description": "The validate_password plugin is deprecated in Aurora MySQL 8.4",
  "detectedProblems": [
      {
        "level": "Warning",
        "dbObject": "validate_password",
        "description": "The validate_password plugin is deprecated and will be removed in a future release. It is recommended to transition to the validate_password component."
      }
  ]
}
```
**解決方法：**  

```
-- Check current plugin status
SELECT plugin_name, plugin_status FROM information_schema.plugins
WHERE plugin_name = 'validate_password';

-- Uninstall the plugin
UNINSTALL PLUGIN validate_password;

-- Install the component replacement
INSTALL COMPONENT 'file://component_validate_password';

-- Verify
SELECT * FROM mysql.component WHERE component_urn LIKE '%validate_password%';
```

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

下列預先檢查會在預先檢查失敗時產生通知，但升級可以繼續。
+ [invalidPrivileges](#v84-invalidPrivileges)

**invalidPrivileges**  
**預先檢查層級：注意**  
**檢查將移除的使用者權限**  
此預先檢查會識別具有在 MySQL 8.4 中移除或修改之權限的使用者帳戶。`SET_USER_ID` 權限會在升級程序中移除。如果未使用權限，則不需要任何動作。否則，請確保它們在升級之前停止使用，因為它們將會遺失。  
**輸出範例：**  

```
{
  "id": "invalidPrivileges",
  "title": "Checks for user privileges that will be removed",
  "status": "OK",
  "description": "Verifies for users containing grants to be removed as part of the upgrade process.",
  "detectedProblems": [
      {
        "level": "Notice",
        "dbObject": "'test_user'@'localhost'",
        "description": "The user 'test_user'@'localhost' has the following privileges that will be removed as part of the upgrade process: SET_USER_ID"
      }
  ]
}
```
**解決方法：**  
這是資訊性通知，不需要採取任何動作。升級程序期間會自動移除`SET_USER_ID`權限。  
不過，如果您的應用程式依賴 `SET_USER_ID`權限，請在升級之前檢閱和更新您的應用程式。

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

視預先檢查輸出而定，下列預先檢查可能會傳回錯誤、警告或通知。
+ [authMethodUsage](#v84-authMethodUsage)
+ [pluginUsage](#v84-pluginUsage)
+ [checkTableCommand](#v84-checkTableCommand)

**authMethodUsage**  
**預先檢查層級：錯誤、警告或通知**  
**檢查是否已棄用或無效的使用者身分驗證方法**  
此預先檢查會使用已棄用或將在 MySQL 8.4 中移除的身分驗證方法識別使用者帳戶。從 MySQL 8.4.0 開始，身分`mysql_native_password`驗證外掛程式預設為已棄用和停用。外掛程式可能會在未來版本中移除。  
嚴重性等級是根據特徵生命週期動態的 - 棄用前通知、棄用後警告、移除後錯誤。  
**輸出範例：**  

```
{
  "id": "authMethodUsage",
  "title": "Check for deprecated or invalid user authentication methods.",
  "status": "OK",
  "description": "Some users are using authentication methods that may be deprecated or removed, please review the details below.",
  "detectedProblems": [
      {
        "level": "Warning",
        "dbObject": "testuser@localhost",
        "description": ""
      }
  ]
}
```
**解決方法：**  
更新使用者帳戶以使用`caching_sha2_password`身分驗證：  

```
ALTER USER '{{username}}'@'{{host}}' IDENTIFIED WITH caching_sha2_password BY '{{new_password}}';
```
Aurora 內部系統帳戶不需要任何動作。它們會在升級程序期間自動更新。嘗試手動修改這些帳戶可能會導致 Aurora 功能發生問題。

**pluginUsage**  
**預先檢查層級：錯誤、警告或通知**  
**檢查是否已棄用或移除的外掛程式用量**  
此預先檢查可識別已在 MySQL 8.4 中棄用或移除的外掛程式。它會檢查所有作用中的外掛程式，並報告其棄用狀態。嚴重性等級會根據特徵生命週期而動態。  
**輸出範例：**  

```
{
  "id": "pluginUsage",
  "title": "Check for deprecated or removed plugin usage.",
  "status": "OK",
  "description": "The following plugins are ACTIVE and they have been deprecated or removed.",
  "detectedProblems": [
      {
        "level": "Error",
        "dbObject": "keyring_file",
        "description": "The 'keyring_file' plugin is removed as of MySQL 8.4.0. It must not be used anymore, please use the 'component_keyring_file' component instead."
      }
  ]
}
```
**解決方法：**  
解除安裝已取代的外掛程式，並安裝其元件替換：  

```
-- Check installed plugins
SELECT plugin_name, plugin_status FROM information_schema.plugins
WHERE plugin_name IN ('keyring_file', 'keyring_encrypted_file', 'keyring_oci', 'authentication_fido');

-- Uninstall and replace (example for keyring_file)
UNINSTALL PLUGIN keyring_file;
INSTALL COMPONENT 'file://component_keyring_file';

-- Verify
SELECT * FROM mysql.component WHERE component_urn LIKE '%keyring%';
```
下表列出已取代的外掛程式及其取代項目：      
[See the AWS documentation website for more details](http://docs.aws.amazon.com/zh_tw/AmazonRDS/latest/AuroraUserGuide/AuroraMySQL.upgrade-prechecks-v3-to-v84.descriptions.html)

**checkTableCommand**  
**預先檢查層級：錯誤、警告或通知**  
**`check table x for upgrade` 命令報告的問題**  
此預先檢查會在所有使用者資料表上執行 `CHECK TABLE ... FOR UPGRADE`命令，以識別結構問題、已棄用的功能或與 MySQL 8.4 不相容。命令會執行資料表結構和中繼資料的全面驗證。  
與其他預先檢查不同，它可能會根據 `CHECK TABLE` 輸出傳回錯誤、警告或通知。如果此預先檢查傳回任何資料表，請在啟動升級之前仔細檢閱它們以及傳回程式碼和訊息。  
**輸出範例：**  

```
{
  "id": "checkTableCommand",
  "title": "Issues reported by 'check table x for upgrade' command",
  "status": "OK",
  "description": "Issues reported by 'check table x for upgrade' command",
  "detectedProblems": [
      {
        "level": "Error",
        "dbObject": "test.orphaned_view",
        "description": "View 'test.orphaned_view' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them"
      },
      {
        "level": "Error",
        "dbObject": "test.orphaned_view",
        "description": "Corrupt"
      }
  ]
}
```
**解決方法：**  
檢閱報告的物件，並在升級之前修正或移除它們。常見問題包括：  
+ 參考無效資料表或資料欄的檢視 - 捨棄或重新建立檢視。
+ 損毀的資料表 - 執行`REPAIR TABLE`或重新建立資料表。
+ 屬性遺失的觸發條件 `CREATED`- 重新建立觸發條件。
如需詳細資訊，請參閱 MySQL 文件中的 [CHECK TABLE 陳述式](https://dev.mysql.com/doc/refman/8.4/en/check-table.html)。