§ Migrating from MySQL to GreatSQL
This article introduces how to migrate/upgrade from MySQL to the GreatSQL database.
§ Why Migrate/Upgrade
Compared with MySQL Community Edition, GreatSQL has many excellent features, including but not limited to the following:
| 1. Main Features | GreatSQL 8.0.32-27 | MySQL 8.0.32 |
|---|---|---|
| Open Source | ✔️ | ✔️ |
| ACID Integrity | ✔️ | ✔️ |
| MVCC | ✔️ | ✔️ |
| Row Locking | ✔️ | ✔️ |
| Automatic Crash Recovery | ✔️ | ✔️ |
| Table Partitioning | ✔️ | ✔️ |
| Views | ✔️ | ✔️ |
| Subqueries | ✔️ | ✔️ |
| Triggers | ✔️ | ✔️ |
| Stored Programs | ✔️ | ✔️ |
| Foreign Keys | ✔️ | ✔️ |
| Window Functions | ✔️ | ✔️ |
| Common Table Expressions (CTE) | ✔️ | ✔️ |
| Geographic Information (GIS) | ✔️ | ✔️ |
| GTID-based Replication | ✔️ | ✔️ |
| Group Replication (MGR) | ✔️ | ✔️ |
| MyRocks Engine | ✔️ | ❌ |
| LoongArch Support | ✔️ | ❌ |
| 2. Performance Extensions | GreatSQL 8.0.32-27 | MySQL 8.0.32 |
| Rapid Engine | ✔️ | HeatWave only on cloud |
| Turbo Engine | ✔️ | ❌ |
| NUMA Affinity Optimization | ✔️ | ❌ |
| Non-blocking DDL | ✔️ | ❌ |
| Faster Import for Tables without Primary Keys | ✔️ | ❌ |
| InnoDB Parallel Query | ✔️ | Primary-key scan only |
| Parallel LOAD DATA | ✔️ | ❌ |
| Lock-free InnoDB Transaction ReadView Optimization | ✔️ | ❌ |
| InnoDB Transaction Large Lock Splitting Optimization | ✔️ | ❌ |
| InnoDB Resource Groups | ✔️ | ✔️ |
| Custom InnoDB Page Size | ✔️ | ✔️ |
| Contention-Aware Transaction Scheduling | ✔️ | ✔️ |
| InnoDB Mutex Splitting Optimization | ✔️ | ❌ |
| MEMORY Engine Optimization | ✔️ | ❌ |
| InnoDB Flushing Optimization | ✔️ | ❌ |
| Parallel Doublewrite Buffer | ✔️ | ✔️ |
| Fast InnoDB Index Creation Optimization | ✔️ | ❌ |
| Single-column Compression for VARCHAR/BLOB/JSON | ✔️ | ❌ |
| Column Compression Info in Data Dictionary | ✔️ | ❌ |
| 3. Developer Improvements | GreatSQL 8.0.32-27 | MySQL 8.0.32 |
| X API | ✔️ | ✔️ |
| JSON | ✔️ | ✔️ |
| NoSQL Socket-Level Interface | ✔️ | ✔️ |
| InnoDB Full-Text Search Improvements | ✔️ | ❌ |
| More Hash/Digest Functions | ✔️ | ❌ |
| Oracle Compatibility - Data Types | ✔️ | ❌ |
| Oracle Compatibility - Functions | ✔️ | ❌ |
| Oracle Compatibility - SQL Syntax | ✔️ | ❌ |
| Oracle Compatibility - Stored Routines | ✔️ | ❌ |
| 4. Basic Feature Improvements | GreatSQL 8.0.32-27 | MySQL 8.0.32 |
| MGR - Zone Tags | ✔️ | ❌ |
| MGR - Arbitrator Nodes | ✔️ | ❌ |
| MGR - Dynamic VIP for Read/Write Nodes | ✔️ | ❌ |
| MGR - Fast Single-Primary Mode | ✔️ | ❌ |
| MGR - Smart Primary Election | ✔️ | ❌ |
| MGR - New Flow Control Algorithm | ✔️ | ❌ |
| MGR - Network Partition Exception Handling | ✔️ | ❌ |
| MGR - Node Abnormal Exit Handling | ✔️ | ❌ |
| MGR - Node Disk Full Handling | ✔️ | ❌ |
| MGR - Automatic Donor Selection | ✔️ | ❌ |
| Clone Incremental Backup | ✔️ | ❌ |
| Clone Backup Compression | ✔️ | ❌ |
| Binlog Read Speed Limit | ✔️ | ❌ |
| Number of information_schema Tables | 95 | 65 |
| Global Performance and Status Metrics | 853 | 434 |
| Optimizer Histograms | ✔️ | ✔️ |
| Per-Table Performance Metrics | ✔️ | ❌ |
| Per-Index Performance Metrics | ✔️ | ❌ |
| Per-User Performance Metrics | ✔️ | ❌ |
| Per-Client Performance Metrics | ✔️ | ❌ |
| Per-Thread Performance Metrics | ✔️ | ❌ |
| Global Query Response Time Statistics | ✔️ | ❌ |
| Enhanced SHOW ENGINE INNODB STATUS | ✔️ | ❌ |
| Enhanced Rollback Segment Information | ✔️ | ❌ |
| Enhanced Temporary Table Information | ✔️ | ❌ |
| Enhanced User Statistics | ✔️ | ❌ |
| Enhanced Slow Log Information | ✔️ | ❌ |
| 5. Security Improvements | GreatSQL 8.0.32-27 | MySQL 8.0.32 |
| National Cryptographic (GM) Support | ✔️ | ❌ |
| Backup Encryption | ✔️ | ❌ |
| Auditing | ✔️ | Enterprise only |
| Data Masking | ✔️ | ❌ |
| Last Login Recording | ✔️ | ❌ |
| SQL Roles | ✔️ | ✔️ |
| SHA-2 Password Hashing | ✔️ | ✔️ |
| Password Rotation Policy | ✔️ | ✔️ |
| PAM Authentication Plugin | ✔️ | Enterprise only |
| Keyring Stored in Files | ✔️ | ✔️ |
| Keyring Stored in Hashicorp Vault | ✔️ | Enterprise only |
| InnoDB Data Encryption | ✔️ | ✔️ |
| InnoDB Log Encryption | ✔️ | ✔️ |
| InnoDB Tablespace File Encryption | ✔️ | ✔️ |
| Binary Log Encryption | ✔️ | ❌ |
| Temporary File Encryption | ✔️ | ❌ |
| Enforced Encryption | ✔️ | ❌ |
| 6. Operational Convenience Improvements | GreatSQL 8.0.32-27 | MySQL 8.0.32 |
| Atomic DDL | ✔️ | ✔️ |
| Data Dictionary Stored in InnoDB Tables | ✔️ | ✔️ |
| Fast DDL | ✔️ | ✔️ |
| SET PERSIST | ✔️ | ✔️ |
| Invisible Indexes | ✔️ | ✔️ |
| Thread Pool | ✔️ | Enterprise only |
| Backup Locks | ✔️ | ❌ |
| Extended SHOW GRANTS | ✔️ | ❌ |
| Extended Corrupted Table Actions | ✔️ | ❌ |
| Kill Idle Transactions | ✔️ | ❌ |
| Extended START TRANSACTION WITH CONSISTENT SNAPSHOT | ✔️ | ❌ |
§ Preparation Before Migration/Upgrade
First download the GreatSQL 8.0 installation package. It is recommended to choose the latest GreatSQL 8.0.32-27 release (opens new window). Whether to choose RPM or binary tarball depends on the specific situation and personal preference.
It is recommended to use GreatSQL Shell for the pre-upgrade check and fix any possible problems in advance. For details, see: Upgrade Check.
This article uses the binary tarball installation method.
Before the formal migration/upgrade, be sure to back up your data. You can use any of the following methods:
- Stop for maintenance, copy the current database directory, and make a full physical backup. This method is the fastest to restore.
- Use backup tools such as mysqldump/xtrabackup to perform a full backup.
- Use source-replica replication or MGR to perform a backup on one of the nodes, or temporarily take a node offline/exit as a standby node.
Next, determine which of the following situations this migration/upgrade belongs to:
- Migrate+upgrade from MySQL 5.7 directly to GreatSQL 8.0.32 in one go.
- Migrate/upgrade from MySQL 8.0.32 and lower versions to GreatSQL 8.0.32.
- For migrating+upgrading from MySQL 5.6 and lower versions to GreatSQL 8.0.32, you should first upgrade the major versions one by one, e.g., 5.5=>5.6, 5.6=>the latest 5.7, and then upgrade to GreatSQL 8.0.32-27 in one go.
For the first two situations, refer to the method in the document: Upgrading GreatSQL 5.7 to 8.0 to migrate/upgrade. The process is exactly the same.
This article focuses on the third situation.
§ Migration Process
The GreatSQL database does not support direct in-place downgrading, so the logical backup + import method is required for migration.
If you start the mysqld binary of GreatSQL 8.0.32-27 directly on the datadir of MySQL 8.0.33 or higher versions, you may see errors similar to the following:
[ERROR] [MY-012530] [InnoDB] Unknown redo log format (5). Please follow the instructions at http://dev.mysql.com/doc/refman/8.0/en/ upgrading-downgrading.html.
[ERROR] [MY-012930] [InnoDB] Plugin initialization aborted with error Generic error.
[ERROR] [MY-010334] [Server] Failed to initialize DD Storage Engine
[ERROR] [MY-010020] [Server] Data Dictionary initialization failed.
[ERROR] [MY-010119] [Server] Aborting
2
3
4
5
Even after restoring with files physically backed up by the xtrabackup tool, it still cannot be started, and similar error messages will be reported.
Therefore, there is only one method, and that is logical backup + import.
First, use mysqldump to back up all data:
mysqldump -S/data/MySQL/mysql.sock -A --triggers --routines --events > /backup/MySQL/fullbackup-`date +'%Y%m%d'`.sql
Copy the backup file to the GreatSQL environment and import it. During the import, errors may be reported; just add the -f option and ignore these errors (some tables in the higher version do not exist in the lower version, so skip them).
$ mysql -S/data/GreatSQL/mysql.sock -f < /backup/MySQL/fullbackup-`date +'%Y%m%d'`.sql
#Error messages similar to the following may be reported; just ignore them
...
ERROR 3723 (HY000) at line 543: The table 'replication_group_configuration_version' may not be created in the reserved tablespace 'mysql'.
ERROR 1146 (42S02) at line 554: Table 'mysql.replication_group_configuration_version' doesn't exist
ERROR 1146 (42S02) at line 555: Table 'mysql.replication_group_configuration_version' doesn't exist
ERROR 1146 (42S02) at line 556: Table 'mysql.replication_group_configuration_version' doesn't exist
ERROR 1146 (42S02) at line 557: Table 'mysql.replication_group_configuration_version' doesn't exist
ERROR 3723 (HY000) at line 567: The table 'replication_group_member_actions' may not be created in the reserved tablespace 'mysql'.
ERROR 1146 (42S02) at line 583: Table 'mysql.replication_group_member_actions' doesn't exist
ERROR 1146 (42S02) at line 584: Table 'mysql.replication_group_member_actions' doesn't exist
ERROR 1146 (42S02) at line 585: Table 'mysql.replication_group_member_actions' doesn't exist
ERROR 1146 (42S02) at line 586: Table 'mysql.replication_group_member_actions' doesn't exist
...
2
3
4
5
6
7
8
9
10
11
12
13
14
15
If the amount of data is large, the logical backup + import process takes a long time, so be mentally prepared.
§ Downgrading to GreatSQL 8.0.32-27
If you want to downgrade from a version after MySQL 8.0.32 to GreatSQL 8.0.32-27, you need to use the logical backup + logical import method to complete the downgrade (it is not supported to start GreatSQL 8.0.32-27 in-place on the original datadir to complete the downgrade replacement). In addition, on the first restart after the logical backup import is completed, be sure to set upgrade=FORCE to force the upgrade of all data tables, including system tables.
The downgrade process is roughly as follows:
- Logically back up all data on the higher version
mysqldump -S/data/MySQL/mysql.sock -A --triggers --routines --events --single-transaction > /data/backup/fulldump.sql
- Import the logical backup file in the GreatSQL 8.0.32-27 environment to complete logical restore
mysql -S/data/GreatSQL/mysql.sock -f < /data/backup/fulldump.sql
- Modify my.cnf to ensure
upgrade=FORCEis set
[mysqld]
upgrade=FORCE
2
- Restart GreatSQL to complete the downgrade
systemctl restart greatsql
During the restart, you can see a forced upgrade process similar to the following in the logs
[Note] [MY-013387] [Server] Upgrading system table data.
[Note] [MY-013385] [Server] Upgrading the sys schema.
[Note] [MY-013400] [Server] Upgrade of help tables started.
[Note] [MY-013400] [Server] Upgrade of help tables completed.
[Note] [MY-013394] [Server] Checking 'mysql' schema.
[Note] [MY-013394] [Server] Checking 'sys' schema.
[System] [MY-013381] [Server] Server upgrade from '80032' to '80032' completed.
2
3
4
5
6
7
If upgrade=FORCE is not set to force the upgrade of all tables, corruption errors may occur in the system table mysql.procs_priv, and an error similar to the following may be reported when creating a user:
greatsql> create user tpch identified by 'tpch';
ERROR 1728 (HY000): Cannot load from mysql.procs_priv. The table is probably corrupted
2
§ Notes
The MGR group view UUID feature (group_replication_view_change_uuid (opens new window)) was introduced in MySQL 8.0.26. Therefore, if the version of a current MGR cluster is 8.0.25 or lower, it cannot be smoothly upgraded/migrated to 8.0.26. You need to apply for a downtime maintenance window, perform in-place upgrades on each node of the MGR cluster, and complete the upgrade from 8.0.25 to 8.0.26 or higher.
For details, please refer to: Smoothly upgrading an MGR cluster from GreatSQL-8.0.25 to GreatSQL-8.0.32 (opens new window).
Reference Documents
- Percona Server for MySQL In-Place Upgrading Guide: From 5.7 to 8.0 (opens new window)
- Changes in MySQL 8.0 (opens new window)
- Before You Begin (opens new window)
- What the MySQL Upgrade Process Upgrades (opens new window)
- Smoothly upgrading MySQL 5.7 MGR to GreatSQL 5.7 (opens new window)
Scan the QR code to follow our WeChat official account
