§ 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. Major Features | GreatSQL 8.4.4-4 | MySQL 8.4.4 |
|---|---|---|
| Open Source | ✔️ | ✔️ |
| ACID Integrity | ✔️ | ✔️ |
| MVCC Features | ✔️ | ✔️ |
| Row Locks Supported | ✔️ | ✔️ |
| 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 Architecture Support | ✔️ | ❌ |
| 2. Performance Enhancement Extensions | GreatSQL 8.4.4-4 | MySQL 8.4.4 |
| Rapid Engine | ✔️ | HeatWave (cloud only) |
| Turbo Engine | ✔️ | ❌ |
| NUMA Affinity Optimization | ✔️ | ❌ |
| Non-Blocking DDL | ✔️ | ❌ |
| Import Optimization for Tables Without Primary Key | ✔️ | ❌ |
| Parallel LOAD DATA | ✔️ | ❌ |
| InnoDB Transaction ReadView Lock-Free Optimization | ✔️ | ❌ |
| InnoDB Transaction Large Lock Splitting Optimization | ✔️ | ❌ |
| InnoDB Resource Groups | ✔️ | ✔️ |
| Custom InnoDB Page Size | ✔️ | ✔️ |
| Contention-Aware Transaction Scheduling | ✔️ | ✔️ |
| InnoDB Mutexes Splitting Optimization | ✔️ | ❌ |
| MEMORY Engine Optimization | ✔️ | ❌ |
| InnoDB Flushing Optimization | ✔️ | ❌ |
| Parallel Doublewrite Buffer | ✔️ | ✔️ |
| InnoDB Fast Index Creation Optimization | ✔️ | ❌ |
| Single-Column Compression for VARCHAR/BLOB/JSON Types | ✔️ | ❌ |
| Single-Column Compression Information in Data Dictionary | ✔️ | ❌ |
| 3. Developer-Oriented Improvements | GreatSQL 8.4.4-4 | MySQL 8.4.4 |
| 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 Programs | ✔️ | ❌ |
| 4. Basic Feature Enhancements | GreatSQL 8.4.4-4 | MySQL 8.4.4 |
| MGR Enhancement - Zone Tags | ✔️ | ❌ |
| MGR Enhancement - Arbitrator Nodes | ✔️ | ❌ |
| MGR Enhancement - VIP Binding for Read/Write Nodes | ✔️ | ❌ |
| MGR Enhancement - Fast Single-Primary Mode | ✔️ | ❌ |
| MGR Enhancement - Smart Primary Election Mechanism | ✔️ | ❌ |
| MGR Enhancement - New Flow Control Algorithm | ✔️ | ❌ |
| MGR Enhancement - Network Partition Exception Handling | ✔️ | ❌ |
| MGR Enhancement - Abnormal Node Exit Handling | ✔️ | ❌ |
| MGR Enhancement - Full Node Disk Handling | ✔️ | ❌ |
| MGR Enhancement - Automatic Donor Node Selection | ✔️ | ❌ |
| Clone Incremental Backup | ✔️ | ❌ |
| Clone Backup Compression | ✔️ | ❌ |
| Binlog Read Rate 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 | ✔️ | ❌ |
| SHOW ENGINE INNODB STATUS Enhancement | ✔️ | ❌ |
| Rollback Segment Information Enhancement | ✔️ | ❌ |
| Temporary Table Information Enhancement | ✔️ | ❌ |
| User Statistics Enhancement | ✔️ | ❌ |
| Slow Query Log Enhancement | ✔️ | ❌ |
| 5. Security Enhancements | GreatSQL 8.4.4-4 | MySQL 8.4.4 |
| National Cryptographic Algorithm Support | ✔️ | ❌ |
| Backup Encryption | ✔️ | ❌ |
| Auditing | ✔️ | Enterprise Edition only |
| Data Masking | ✔️ | ❌ |
| SQL Roles | ✔️ | ✔️ |
| SHA-2 Password Hashing | ✔️ | ✔️ |
| Password Rotation Policy | ✔️ | ✔️ |
| PAM Authentication Plugin | ✔️ | Enterprise Edition only |
| Keyring Stored in File | ✔️ | ✔️ |
| Keyring Stored in Hashicorp Vault | ✔️ | Enterprise Edition only |
| InnoDB Data Encryption | ✔️ | ✔️ |
| InnoDB Log Encryption | ✔️ | ✔️ |
| InnoDB Tablespace File Encryption | ✔️ | ✔️ |
| Binary Log Encryption | ✔️ | ❌ |
| Temporary File Encryption | ✔️ | ❌ |
| Forced Encryption | ✔️ | ❌ |
| 6. Operations Convenience Enhancements | GreatSQL 8.4.4-4 | MySQL 8.4.4 |
| DDL Atomicity | ✔️ | ✔️ |
| Data Dictionary Stored in InnoDB Tables | ✔️ | ✔️ |
| Fast DDL | ✔️ | ✔️ |
| SET PERSIST | ✔️ | ✔️ |
| Invisible Indexes | ✔️ | ✔️ |
| Thread Pool | ✔️ | Enterprise Edition only |
| Backup Locks | ✔️ | ❌ |
| SHOW GRANTS Extension | ✔️ | ❌ |
| Table Corruption Action Extension | ✔️ | ❌ |
| Kill Inactive Transactions | ✔️ | ❌ |
| START TRANSACTION WITH CONSISTENT SNAPSHOT Extension | ✔️ | ❌ |
§ Preparation Before Migration/Upgrade
First download the GreatSQL 8.4 installation package. It is recommended to choose the latest GreatSQL 8.4.4-4 release (opens new window). Whether to choose RPM or binary tarball depends on the specific situation and personal preference.
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/xtrabackupto perform a full backup. - Use source-replica replication or MGR to perform a backup on one of the members, or temporarily take a member offline/exit as a standby member.
Next, determine which of the following situations this migration/upgrade belongs to:
- Migrate+upgrade from MySQL 8.0 directly to GreatSQL 8.4.4-4 in one go.
- Migrate/upgrade from Percona 8.4.4-4 and earlier versions to GreatSQL 8.0.32.
- Migrate+upgrade from MySQL 5.7 and lower versions to GreatSQL 8.4.4-4.
For the first two situations, refer to the method in the document: Upgrading from GreatSQL 8.0 to 8.4 to migrate/upgrade. The process is exactly the same.
For the third situation, you should first upgrade the major versions one by one, e.g., 5.6 => 5.7, 5.7 => the latest 8.0, and then upgrade to GreatSQL 8.4.4-4. You can also use mysqldump to fully back up the data in the lower-version database and then import it into the GreatSQL 8.4.4-4 database environment to complete the upgrade in one go.
§ Downgrading to GreatSQL 8.4.4-4
In the GreatSQL 8.4 LTS release, in-place upgrade/downgrade between different minor versions is supported, while in other releases direct in-place downgrade is not supported. Therefore, it is recommended to use the logical backup + import method to complete the migration.
If you want to downgrade from MySQL 9.0 and later versions to GreatSQL 8.4.4-4, you need to use the logical backup + logical import method to complete the downgrade (it is not supported to start GreatSQL 8.4.4-4 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:
1. 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
2. Import the logical backup file in the GreatSQL 8.4.4-4 environment to complete logical restore
mysql -S/data/GreatSQL/mysql.sock -f < /data/backup/fulldump.sql
3. Modify my.cnf to ensure upgrade=FORCE is set
[mysqld]
upgrade=FORCE
2
4. 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:
[System] [MY-013381] [Server] Server upgrade from '80404' to '80404' started.
[System] [MY-013381] [Server] Server upgrade from '80404' to '80404' completed.
2
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
After the upgrade/downgrade is complete, remember to comment out the upgrade=FORCE option in the my.cnf file, or change it to upgrade=AUTO.
Reference Documents
- Upgrade from 8.0 to 8.4 overview (opens new window)
- Changes in MySQL 8.4 (opens new window)
- Upgrade Before You Begin (opens new window)
- What the MySQL Upgrade Process Upgrades (opens new window)
- Smooth upgrade of MySQL 5.7 MGR to GreatSQL 5.7 (opens new window)
Scan the QR code to follow our WeChat official account
