Updated on 2025-09-09 GMT+08:00

Overview of MySQL Compatibility

Overview of M-compatible Mode

M-compatible Mode compares GaussDB in M-compatible mode (sql_compatibility set to 'M') with MySQL 5.7. Only compatibility features added later than GaussDB Kernel 505.1.0 are described. You are advised to view the specifications and restrictions of the features in M Compatibility Developer Guide.

GaussDB is compatible with MySQL in terms of data types, SQL functions, and database objects.

The execution plan, optimization, and EXPLAIN result in GaussDB are different from those in MySQL.

GaussDB and MySQL implement different underlying frameworks. Therefore, there are still some differences between GaussDB and MySQL.

  • The M-compatible mode delivers high compatibility with MySQL in terms of syntax, data types, metadata, and protocols. The B-compatible mode will not evolve because it is not compatible with the MySQL architecture.
  • The underlying architecture of GaussDB in M-compatible mode is different from that of MySQL. Therefore, the performance of querying the same schemas under information_schema and m_schema may be different from that in MySQL. For details, see "Schemas" in M Compatibility Developer Guide. For example, the execution of the count function cannot be optimized. The time consumed by the SELECT * and SELECT COUNT(*) statements is similar.

Overview of B-compatible Mode

B-compatible Mode compares GaussDB in B-compatible mode (that is, when sql_compatibility is set to 'B', b_format_version is set to '5.7', and b_format_dev_version is set to 's1') with MySQL 5.7. Only compatibility features added later than GaussDB Kernel 503.0.0 are described. You are advised to view the specifications and restrictions of the features in Developer Guide.

  • The M-compatible mode delivers high compatibility with MySQL in terms of syntax, data types, metadata, and protocols. The B-compatible mode will not evolve because it is not compatible with the MySQL architecture.
  • Only the features described in B-compatible Mode are compatible with MySQL. The behavior of other features remain the same as that in GaussDB.
  • Currently, the implementation logic of B-compatible mode (sql_compatibility set to 'B') is similar to that of MySQL-compatible mode (sql_compatibility set to 'MYSQL') in the distributed mode.

GaussDB is compatible with MySQL in terms of data types, SQL functions, and database objects.

GaussDB and MySQL implement different underlying frameworks. Therefore, there are still some differences between GaussDB and MySQL.

Database and Schema Design

MySQL data objects include database, table, index, view, trigger, and proc, mapping those in GaussDB hierarchically and maybe in a 1:N relationship, as shown in the following figure.

Figure 1 Differences between databases and schemas in MySQL and GaussDB
  • In MySQL, database and schema are synonyms. In GaussDB, a database can have multiple schemas. In this feature, each database in MySQL is mapped to a schema in GaussDB.
  • In MySQL, an index belongs to a table. In GaussDB, an index belongs to a schema. As a result, an index name must be unique in a schema in GaussDB and must be unique in a table in MySQL. This difference will be retained as a current constraint.