升級(jí)版本選擇準(zhǔn)則和建議

MySQL升級(jí)必須遵循以下一些原則和建議:

支持從MySQL5.7升級(jí)到8.0。請(qǐng)注意,僅支持正式發(fā)行版本之間的升級(jí)。

  • 不支持跨大版本的升級(jí),如從5.6升級(jí)到8.0是不支持的。
  • 建議升級(jí)大版本前先升級(jí)到當(dāng)前版本的最近小版本,如5.7先升級(jí)到5.7.35后再升級(jí)到8.0。
  • 在大版本內(nèi)部GA的小版本可以直接升級(jí),如從8.0.9直接升級(jí)到8.0.26。
  • MySQL8.0的一些變化

    在升級(jí)到8.0之前需要充分考慮版本變化帶來(lái)的使用兼容性的問(wèn)題,其中不兼容的部分需要特別關(guān)注,建議升級(jí)大版本前做充分的測(cè)試。下面簡(jiǎn)單介紹下MySQL8.0的部分變化。

    • 數(shù)據(jù)字典

    不同于之前的版本將字典數(shù)據(jù)存儲(chǔ)在元數(shù)據(jù)文件和非事務(wù)系統(tǒng)表中,MySQL8.0將包含數(shù)據(jù)庫(kù)對(duì)象的全局?jǐn)?shù)據(jù)字典存儲(chǔ)在事務(wù)表中。在使用上如果設(shè)置了innodb_read_only 參數(shù)會(huì)導(dǎo)致所有表的創(chuàng)建、刪除、analyze、修改表引擎操作無(wú)法執(zhí)行。CREATE TABLE dst_tbl LIKE src_tbl 要求src_tbl必須是base table。mysqldump和mysqlpump不會(huì)導(dǎo)出information_schema,不會(huì)導(dǎo)出MySQL Schema中數(shù)據(jù)字典表,需導(dǎo)出存儲(chǔ)過(guò)程和事件需指定–routines和--events選項(xiàng),并且用戶需要全局selet權(quán)限。

    • Authentication Plugin

    MySQL8.0將默認(rèn)身份驗(yàn)證插件從mysql_native_password變更為caching_sha2_password,客戶端需要驗(yàn)證現(xiàn)有版本是否支持。

    • Configuration Changes
    • MySQL8.0開(kāi)始只有InnoDB和NDB引擎支持分區(qū)表,升級(jí)前需確保不存在非InnoDB引擎的分區(qū)表。
    • 部分error code被啟用,詳見(jiàn)
    • 默認(rèn)字符集從latin1變更為utf8mb4,默認(rèn)排序規(guī)則為utf8mb4_0900_ai_ci。注意這可能會(huì)導(dǎo)致新舊數(shù)據(jù)庫(kù)對(duì)象的字符集不一致,造成隱式類(lèi)型轉(zhuǎn)換的問(wèn)題。
    • 8.0.11版本開(kāi)始,如使用與初始化配置不同的lower_case_table_names值啟動(dòng)數(shù)據(jù)庫(kù)時(shí)會(huì)報(bào)錯(cuò)。
    • [ERROR] [MY-011087] [Server] Different lower_case_table_names settings for server ('0') and data dictionary ('1').
      [ERROR] [MY-010020] [Server] Data Dictionary initialization failed.
      [ERROR] [MY-010119] [Server] Aborting
    • Server Changes
    • 8.0.11開(kāi)始部分賬戶管理功能被刪除,如Grant命令修改用戶非權(quán)限特性,NO_AUTO_CREATE_USER模式,PASSWORD() 函數(shù)和 old_passwords 系統(tǒng)變量。
    • 8.0.11開(kāi)始刪除了部分兼容 SQL 模式:DB2、MAXDB、MSSQL、MYSQL323、MYSQL40、ORACLE、POSTGRESQL、NO_FIELD_OPTIONS、NO_KEY_OPTIONS、NO_TABLE_OPTIONS。
    • 從 MySQL 8.0.3 開(kāi)始,空間數(shù)據(jù)類(lèi)型允許 SRID 屬性,以明確指示存儲(chǔ)在列中的值的空間參考系統(tǒng) (SRS)。并刪除了部分非ST_前綴的空間函數(shù)。詳見(jiàn)在線切換binlog format增加了更多限制。
    • InnoDB Changes
      • information_Schema中,innodb_sys_% 改名為 innodb_%
      • zlib庫(kù)版本從1.2.3升級(jí)到1.2.11。
      • 只讀變量innodb_directories應(yīng)該包含file-per-table和絕對(duì)路徑創(chuàng)建的通用表空間文件的路徑。
      • undo日志從系統(tǒng)表空間移出。默認(rèn)會(huì)在innodb_undo_directory指定位置(未指定則在data dir)創(chuàng)建兩個(gè)undo表空間。從5.7升級(jí)到8.0時(shí)innodb-fast-shutdown需設(shè)置成0。
      • 8.0.17開(kāi)始在創(chuàng)建表空間時(shí),路徑不允許含 circular directory reference(/../);升級(jí)前可以查詢INFORMATION_SCHEMA.INNODB_DATAFILES表檢查表空間路徑。mysql> CREATE TABLESPACE ts11 ADD DATAFILE '/data/mysql/log/test/..;;
        ERROR 3121 (HY000): The ADD DATAFILE filepath cannot contain circular directory references.
        mysql> CREATE TABLESPACE ts11 ADD DATAFILE '/data/mysql/log;;
        Query OK, 0 rows affected sec)
    • SQL change
      • group by 不再支持DESC和ASC,GROUP BY {col_name | expr | position}, ... [WITH ROLLUP]]
      • 保留字變更。
      • 升級(jí)后建議測(cè)試optimizer hints,在8.0中部分hint可能不再適用。
    • 部分默認(rèn)配置的變化。

    升級(jí)過(guò)程包含哪些操作

    升級(jí)MySQL時(shí)需要對(duì)現(xiàn)版本MySQL中的數(shù)據(jù)字典和元數(shù)據(jù)等進(jìn)行更新。在MySQL Schema中需更新數(shù)據(jù)字典表和系統(tǒng)表,在其他Schema中需要更新一些內(nèi)置的MySQL持有的表,如performance_Schema、information_schema和sys schema等。

    升級(jí)過(guò)程大致分為兩個(gè)部分,升級(jí)數(shù)據(jù)字典和升級(jí)服務(wù)。

    • 升級(jí)數(shù)據(jù)字典包括升級(jí)MySQL Schema中的數(shù)據(jù)字典表,以及performance schema,information_schema。升級(jí)數(shù)據(jù)字典表時(shí),如當(dāng)前版本低于期望版本,則服務(wù)器將創(chuàng)建新版本的數(shù)據(jù)字典表并將持久化的元數(shù)據(jù)拷貝到新表,在新舊表做原子性替換后重新初始化數(shù)據(jù)字典。服務(wù)器啟動(dòng)后會(huì)按需執(zhí)行,可以使用 --upgrade=NONE(8.0.16以后)或–no-dd-upgrade (8.0.16之前)參數(shù)啟動(dòng)MySQL,阻止數(shù)據(jù)字典表的升級(jí)。
    • 升級(jí)服務(wù)及其余升級(jí)任務(wù),包括MySQL Schema中的非數(shù)據(jù)字典表,sys schema和用戶schema。

    在8.0.16之前需使用mysql_upgrade執(zhí)行除數(shù)據(jù)字典表外的其余升級(jí)步驟,在8.0.16以后該步驟由MySQL服務(wù)在啟動(dòng)后執(zhí)行。MySQL服務(wù)會(huì)根據(jù)升級(jí)到的版本以及in-place或logical升級(jí)的指示確定是否執(zhí)行所有的升級(jí)步驟。

    8.0.16開(kāi)始啟動(dòng)參數(shù)–upgrade= 控制MySQL服務(wù)在啟動(dòng)時(shí)執(zhí)行自動(dòng)升級(jí)的動(dòng)作。

    --upgrade=AUTO MySQL升級(jí)所有過(guò)時(shí)的內(nèi)容 --upgrade=NONE MySQL跳過(guò)升級(jí)步驟,可能會(huì)導(dǎo)致報(bào)錯(cuò) --upgrade=MINIMAL MySQL在必要時(shí)升級(jí)數(shù)據(jù)字典表,information_schema和information_schema。這可能會(huì)導(dǎo)致部分功能不能正常使用,例如MGR。 --upgrade=FORCE MySQL會(huì)升級(jí)所有的內(nèi)容,這會(huì)檢查所有schema的所有對(duì)象,導(dǎo)致MySQL需要更長(zhǎng)的時(shí)間啟動(dòng)。此模式下MySQL會(huì)重新創(chuàng)建系統(tǒng)表 if they are missing。

    升級(jí)前的檢查

    在執(zhí)行升級(jí)操作前需要做一些檢查工作,確認(rèn)準(zhǔn)備工作是否就緒,避免升級(jí)過(guò)程中出現(xiàn)異常。

    • 可以使用MySQL Shell使用u進(jìn)行檢查,返回內(nèi)容包括不符合遷移要求的問(wèn)題,error的問(wèn)題需要遷移前修改。

    下面的例子中就存在一個(gè)不兼容的問(wèn)題,ymh.t1表是一個(gè)MyISAM引擎的分區(qū)表,需將該表引擎調(diào)整為innodb后方可升級(jí)。

    MySQL JS > u('root@127.0.0.1:3307', {"password":"XXXX", "targetVersion":"8.0.26", "configPath":"/etc;}) The MySQL server at 127.0.0.1:3307, version 5.7.23-log - MySQL Community Server (GPL), will now be checked for compatibility issues for upgrade to MySQL 8.0.26... 1) Usage of old temporal type No issues found 2) Usage of db objects with names conflicting with new reserved keywords No issues found 3) Usage of utf8mb3 charset No issues found 4) Table names in the mysql schema conflicting with new tables in 8.0 No issues found 5) Partitioned tables using engines with non native partitioning Error: In MySQL 8.0 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 MySQL 8.0. 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. More information: ymh.t1 - MyISAM engine does not support native partitioning 6) Foreign key constraint names longer than 64 characters No issues found 7) Usage of obsolete MAXDB sql_mode flag No issues found 8) Usage of obsolete sql_mode flags No issues found 9) ENUM/SET column definitions containing elements longer than 255 characters No issues found 10) Usage of partitioned tables in shared tablespaces No issues found 11) Circular directory references in tablespace data file paths No issues found 12) Usage of removed functions No issues found 13) Usage of removed GROUP BY ASC/DESC syntax No issues found 14) Removed system variables for error logging to the system log configuration No issues found 15) Removed system variables No issues found 16) System variables with new default values Warning: Following system variables that are not defined in your configuration file will have new default values. Please review if you rely on their current values and if so define them before performing upgrade. More information: back_log - default value will change collation_server - default value will change from latin1_swedish_ci to utf8mb4_0900_ai_ci event_scheduler - default value will change from OFF to ON explicit_defaults_for_timestamp - default value will change from OFF to ON innodb_autoinc_lock_mode - default value will change from 1 (consecutive) to 2 (interleaved) innodb_max_dirty_pages_pct_lwm - default value will change from_0 (%) to 10 (%) innodb_undo_log_truncate - default value will change from OFF to ON innodb_undo_tablespaces - default value will change from 0 to 2 log_error_verbosity - default value will change from 3 (Notes) to 2 (Warning) max_error_count - default value will change from 64 to 1024 optimizer_trace_max_mem_size - default value will change from 16KB to 1MB performance_schema_consumer_events_transactions_current - default value will change from OFF to ON performance_schema_consumer_events_transactions_history - default value will change from OFF to ON transaction_write_set_extraction - default value will change from OFF to XXHASH64 17) Zero Date, Datetime, and Timestamp values 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. More information: global.sql_mode - does not contain either NO_ZERO_DATE or NO_ZERO_IN_DATE which allows insertion of zero dates - of 1 session(s) does not contain either NO_ZERO_DATE or NO_ZERO_IN_DATE which allows insertion of zero dates 18) Schema inconsistencies resulting from file removal or corruption No issues found 19) Tables recognized by InnoDB that belong to a different engine No issues found 20) Issues reported by 'check table x for upgrade' command No issues found 21) New default authentication plugin considerations 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 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: [mysqld] default_authentication_plugin=mysql_native_password However, 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. If you are using replication please take time to understand how the authentication plugin changes may impact you. More information: Errors: 1 Warnings: 17 Notices: 0 1 errors were found. Please correct these issues before upgrading to avoid compatibility issues. #修改t1表引擎為InnoDB mysql> alter table t1 engine=innodb; Query OK, 0 rows affected sec) Records: 0 Duplicates: 0 Warnings: 0

    MySQL Shell的u工具主要做了以下檢查,當(dāng)然我們也可以手動(dòng)進(jìn)行相關(guān)的檢查。

    • 不應(yīng)存在以下問(wèn)題
      • 使用過(guò)時(shí)的數(shù)據(jù)類(lèi)型和函數(shù)的表。如5.6.4之前的不支持小數(shù)點(diǎn)的時(shí)間格式。需在執(zhí)行In-place升級(jí)前執(zhí)行repair table修復(fù)。
      • 沒(méi)有孤立的.frm文件。
      • 觸發(fā)器不能缺失或空的definer或無(wú)效的creation context。
    • 可執(zhí)行以下命令檢查上述問(wèn)題:mysqlcheck -u root -p --all-databases --check-upgrade
    • 不應(yīng)存在非InnoDB或NDB引擎的分區(qū)表,如存在需變更引擎或轉(zhuǎn)換成非分區(qū)表。可通過(guò)以下SQL檢查:
    SELECT TABLE_SCHEMA, TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE ENGINE NOT IN ('innodb', 'ndbcluster') AND CREATE_OPTIONS LIKE '%partitioned%';
    • 檢查是否使用了8.0新增的保留字。
    • MySQL Schema中不應(yīng)存在8.0數(shù)據(jù)字典表同名的表,可用以下SQL檢查:
    SELECT TABLE_SCHEMA, TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE LOWER(TABLE_SCHEMA) = 'mysql' and LOWER(TABLE_NAME) IN ( 'catalogs', 'character_sets', 'check_constraints', 'collations', 'column_statistics', 'column_type_elements', 'columns', 'dd_properties', 'events', 'foreign_key_column_usage', 'foreign_keys', 'index_column_usage', 'index_partitions', 'index_stats', 'indexes', 'parameter_type_elements', 'parameters', 'resource_groups', 'routines', 'schemata', 'st_spatial_reference_systems', 'table_partition_values', 'table_partitions', 'table_stats', 'tables', 'tablespace_files', 'tablespaces', 'triggers', 'view_routine_usage', 'view_table_usage' );
    • 不得有外鍵約束名稱長(zhǎng)度超過(guò) 64 個(gè)字符的表,如存在則刪除后重建。可用以下SQL檢查:
    SELECT TABLE_SCHEMA, TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME IN (SELECT LEFT(SUBSTR(ID,INSTR(ID,'/')+1), INSTR(SUBSTR(ID,INSTR(ID,'/')+1),'_ibfk_')-1) FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN WHERE LENGTH(SUBSTR(ID,INSTR(ID,'/')+1))>64);
    • sql_mode系統(tǒng)參數(shù)不能含前面提到棄用模式。
    • 視圖中不能有顯式定義超過(guò)64個(gè)字符的列名。可查看INFORMATION_SCHEMA.VIEWS檢查。
    • 表和存儲(chǔ)過(guò)程中單個(gè)枚舉和SET列元素不能超過(guò)255個(gè)字符或1020個(gè)字節(jié)。
    • 升級(jí)到8.0.13版本前,包括系統(tǒng)表空間和通用表空間在內(nèi)的共享表空間中不能存在表分區(qū)。
    #5.7版本以下SQL檢查 SELECT DISTINCT NAME, SPACE, SPACE_TYPE FROM INFORMATION_SCHEMA.INNODB_SYS_TABLES WHERE NAME LIKE '%#P#%' AND SPACE_TYPE NOT LIKE 'Single'; #8.0早期版本以下SQL檢查 SELECT DISTINCT NAME, SPACE, SPACE_TYPE FROM INFORMATION_SCHEMA.INNODB_TABLES WHERE NAME LIKE '%#P#%' AND SPACE_TYPE NOT LIKE 'Single'; #如存在,可使用reorganize partition命令將共享表空間中的分區(qū)遷移到 file-per-table表空間 ALTER TABLE $table_name REORGANIZE PARTITION $partition_name INTO (partition_definition TABLESPACE=innodb_file_per_table);
    • 查詢和存儲(chǔ)過(guò)程中不能在group by子句中使用ASC或者DESC。
    • 不能使用8.0中不支持的功能和配置參數(shù)。
    • 從 MySQL 8.0.19 開(kāi)始,如果lower_case_table_names=1,升級(jí)過(guò)程會(huì)檢查表和模式名稱以確保所有字符都是小寫(xiě)。如果發(fā)現(xiàn)表或架構(gòu)名稱包含大寫(xiě)字符,升級(jí)過(guò)程將失敗并顯示錯(cuò)誤。
    mysql> SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME != LOWER(TABLE_NAME) AND TABLE_TYPE = 'BASE TABLE'; mysql> SELECT SCHEMA_NAME FROM INFORMATION_SCHEMA.SCHEMATA WHERE SCHEMA_NAME != LOWER(SCHEMA_NAME);

    如果出現(xiàn)上述問(wèn)題導(dǎo)致的升級(jí)失敗,MySQL會(huì)將變更還原,這時(shí)刪除redo log并重啟5.7版本實(shí)例即可。注意關(guān)閉前一定設(shè)置innodb_fast_shutdown=0。

    Linux系統(tǒng)升級(jí)Binary或Package-based安裝的MySQL

    在這種場(chǎng)景下可以選擇in-place或者logical方式進(jìn)行升級(jí)。

    • in-place升級(jí)

    關(guān)閉現(xiàn)有版本MySQL,將二進(jìn)制或包替換成新版本并在現(xiàn)有數(shù)據(jù)目錄上啟動(dòng)MySQL并執(zhí)行升級(jí)任務(wù)的方式,稱為in-place升級(jí)。升級(jí)過(guò)程分為以下幾步:

    1. 完成升級(jí)前檢查,并處理不合規(guī)問(wèn)題。
    2. 如果使用了XA事務(wù),升級(jí)前通過(guò)命令xa recover未提交XA事務(wù),并使用xa commit或xa rollback命令提交或回滾。
    3. 如當(dāng)前版本低于5.7.11且使用了加密表空間,升級(jí)前輪換keyring的master keyALTER INSTANCE ROTATE INNODB MASTER KEY。
    4. 將innodb_fast_shutdown改為0或1。
    5. 關(guān)閉現(xiàn)版本MySQL。
    6. 升級(jí)MySQL二進(jìn)制文件或軟件包。
    7. 在現(xiàn)有數(shù)據(jù)目錄上啟動(dòng)新版本MySQL。如果有加密的 InnoDB 表空間,請(qǐng)使用 --early-plugin-load選項(xiàng)加載keyring插件。如升級(jí)失敗請(qǐng)刪除redolog,啟動(dòng)5.7版本并修復(fù)錯(cuò)誤,設(shè)置innodb_fast_shutdown為0后關(guān)閉MySQL。再使用8.0版本MySQL啟動(dòng)。
    8. 如目標(biāo)版本小于8.0.16,MySQL啟動(dòng)后還需執(zhí)行mysql_upgrade后重啟MySQL。

    如下所示:

    #當(dāng)前版本為5.7.23 mysql> select @@global.version; +------------------+ | @@global.version | +------------------+ | 5.7.23-log | +------------------+ 1 row in set sec) #使用mysql shell 命令u('root@127.0.0.1:3307', {"password":"XXXXX", "targetVersion":"8.0.26", "configPath":"/etc;}) 檢查升級(jí)到目標(biāo)版本8.0.26,確認(rèn)沒(méi)有error級(jí)別的問(wèn)題 Errors: 0 Warnings: 17 Notices: 0 No fatal errors were found that would prevent an upgrade, but some potential issues were detected. Please ensure that the reported issues are not significant before upgrading. #檢查沒(méi)有未提交的xa事務(wù) mysql> xa recover; Empty set sec) #將innodb_fast_shutdown改為0或1 mysql> set global innodb_fast_shutdown=0;select @@global.innodb_fast_shutdown; Query OK, 0 rows affected sec) +-------------------------------+ | @@global.innodb_fast_shutdown | +-------------------------------+ | 0 | +-------------------------------+ 1 row in set sec) #關(guān)閉MySQL mysql> shutdown; Query OK, 0 rows affected sec) #因目標(biāo)版本8.0.26,直接在現(xiàn)有數(shù)據(jù)目錄上啟動(dòng)新版本MySQL。由MySQL服務(wù)執(zhí)行升級(jí)任務(wù),可指定--upgrade=FORCE參數(shù) [root@node1 ~]# cd /usr/local [root@node1 bin]# ./mysqld_safe --defaults-file=/etc --user=mysql --upgrade=FORCE & [1] 106547 [root@node1 bin]# mysqld_safe Adding '/usr/lib; to LD_PRELOAD for mysqld 2021-10-15T03:24:11.019020Z mysqld_safe Logging to '/data/mysql3307/log;. 2021-10-15T03:24:11.073416Z mysqld_safe Starting mysqld daemon with databases from /data/mysql3307/data #啟動(dòng)后查看當(dāng)前服務(wù)版本,確認(rèn)已升級(jí)到目標(biāo)版本 mysql> \s -------------- mysql Ver 8.0.26 for Linux on x86_64 (Source distribution) Connection id: 11 Current database: Current user: root@127.0.0.1 SSL: Cipher in use is ECDHE-RSA-AES128-GCM-SHA256 Current pager: stdout Using outfile: '' Using delimiter: ; Server version: 8.0.26-debug Source distribution Protocol version: 10 Connection: 127.0.0.1 via TCP/IP Server characterset: utf8mb4 Db characterset: utf8mb4 Client characterset: utf8mb4 Conn. characterset: utf8mb4 TCP port: 3307 Binary data as: Hexadecimal Uptime: 2 min 39 sec Threads: 2 Questions: 11 Slow queries: 0 Opens: 656 Flush tables: 4 Open tables: 35 Queries per second avg: 0.069 --------------
    • logical升級(jí)

    邏輯升級(jí)是指使用邏輯備份從舊版本MySQL中導(dǎo)出數(shù)據(jù),安裝新版本MySQL并導(dǎo)入數(shù)據(jù)的升級(jí)方式。由于可能存在的不兼容問(wèn)題會(huì)導(dǎo)致導(dǎo)入失敗,導(dǎo)出前需要做升級(jí)前檢查,導(dǎo)入前可能還需要對(duì)備份文件進(jìn)行修改。

    升級(jí)步驟如下:

    1. 對(duì)舊版本數(shù)據(jù)做全量導(dǎo)出。mysqldump -u root -p --add-drop-table --routines --events --all-databases --force > da
    2. 關(guān)閉當(dāng)前版本數(shù)據(jù)庫(kù)。
    3. 安裝8.0版本數(shù)據(jù)庫(kù)并初始化(從error log中獲取’root’@'localhost’用戶初始密碼)。
    4. 在新的數(shù)據(jù)目錄中啟動(dòng)MySQL8.0,并重置初始密碼。
    5. 將備份文件導(dǎo)入mysql -u root -p --force < da。如導(dǎo)出文件包含系統(tǒng)表,則不建議導(dǎo)入時(shí)開(kāi)啟GTID(gtid_mode=ON)。
    6. 執(zhí)行剩余的升級(jí)操作。目標(biāo)版本大于8.0.16時(shí)需重啟服務(wù)器,啟動(dòng)時(shí)使用–upgrade=FORCE參數(shù)。8.0.16之前的版本先執(zhí)行mysql_upgrade再重啟MySQL。
    #8.0.16以后的版本 mysqladmin -u root -p shutdown mysqld_safe --user=mysql --datadir=/path/to --upgrade=FORCE & #8.0.16之前的版本 mysql_upgrade -u root -p mysqladmin -u root -p shutdown mysqld_safe --user=mysql --datadir=/path/to & #確認(rèn)升級(jí)成功后,mysql schema中兩張不再使用的表可以自行清理 DROP TABLE my; DROP TABLE my;

    墨天輪原文鏈接:(復(fù)制到瀏覽器或者點(diǎn)擊“閱讀原文”立即查看)

    關(guān)于作者

    楊明翰,云和恩墨服務(wù)總監(jiān)。擁有MySQL、TDSQL、TiDB、openGauss等認(rèn)證。長(zhǎng)期從事MySQL、PG、Redis、MongoDB的數(shù)據(jù)庫(kù)技術(shù)服務(wù)。現(xiàn)負(fù)責(zé)云和恩墨西區(qū)開(kāi)源數(shù)據(jù)庫(kù)交付運(yùn)維工作;熱衷于開(kāi)源數(shù)據(jù)庫(kù)產(chǎn)品的研究。

    END

    由中國(guó)DBA聯(lián)盟和墨天輪主辦的 2021數(shù)據(jù)技術(shù)嘉年華 將于11月19日-20日在北京麗都皇冠假日酒店盛大召開(kāi)。

    1.《數(shù)據(jù)字典怎么導(dǎo)出?終于找到答案了MySQL8.0版本升級(jí)建議及各類(lèi)場(chǎng)景的操作方法》援引自互聯(lián)網(wǎng),旨在傳遞更多網(wǎng)絡(luò)信息知識(shí),僅代表作者本人觀點(diǎn),與本網(wǎng)站無(wú)關(guān),侵刪請(qǐng)聯(lián)系頁(yè)腳下方聯(lián)系方式。

    2.《數(shù)據(jù)字典怎么導(dǎo)出?終于找到答案了MySQL8.0版本升級(jí)建議及各類(lèi)場(chǎng)景的操作方法》僅供讀者參考,本網(wǎng)站未對(duì)該內(nèi)容進(jìn)行證實(shí),對(duì)其原創(chuàng)性、真實(shí)性、完整性、及時(shí)性不作任何保證。

    3.文章轉(zhuǎn)載時(shí)請(qǐng)保留本站內(nèi)容來(lái)源地址,http://f99ss.com/gl/3033557.html