GBase 8c MySQL Protocol Compatibility Guide

Cong Li - Jul 15 - - Dev Community

With version 5.0.0 of GBase 8c, through an abstract protocol layer interface and the dolphin plugin, the B compatibility database (dbcompatibility='B', referred to as B compatibility database hereafter) supports the MySQL protocol. By setting the relevant parameters, users can directly connect to GBase 8c using the MySQL JDBC driver or MySQL command-line client.

Using Dolphin

The plugin is automatically installed and loaded, no manual installation or loading is required.

  1. Use the OM tool to install GBase 8c. Refer to the "GBase 8c V5_5.0.0 Installation and Deployment Manual" for details.

  2. Create a B database and connect to it using the initial user. The Dolphin plugin is enabled by default.

create database dbname with DBCOMPATIBILITY='B';
\q
$gsql -d dbname -p 15400 -U gbase
Enter fullscreen mode Exit fullscreen mode

Dolphin Usage Restrictions

  • Miniature versions are not supported.
  • Deleting the dolphin plugin is not supported.
  • The dolphin plugin can only be created in B compatibility databases.
  • The dolphin plugin needs to create data types, functions, etc., under schemas like pg_catalog. Therefore, loading the dolphin plugin requires initial user permissions. GBase 8c will automatically load the dolphin plugin when the B database is first connected to by the initial user or a user with initial user permissions. If a B compatibility database has never been connected by the initial user or a user with initial user permissions, it will not load the dolphin plugin.
  • All new/modified syntax in dolphin does not support help viewing via \h in the gsql client and does not support auto-completion in the gsql client.
  • Creating the dolphin plugin will delete functions and types with the same name required by the plugin and previously existing dependent objects in the database.
  • The dolphin plugin depends on the public schema and therefore does not support deleting the public schema using the dropschema method.
  • When connecting to a B compatibility database with the dolphin plugin installed, the GUC parameter behavior_compat_options will be modified by default to add the display_leading_zero and select_into_return_null options for compatibility.

Constraints

Supported MySQL Client Versions

  • MySQL JDBC Driver: 5.1.47
  • MySQL Command-Line Client: 5.7.26 to 5.7.42

Unsupported Features

  • Cursors (i.e., fetching data using useCursorFetch and setFetchSize in JDBC) are not supported.
  • Executing stored procedures is not supported.

Usage

Create a B-type database, create a user, and set a MySQL native password (you can grant privileges to the new user using the GRANT command as needed):

CREATE DATABASE proto_test_db DBCOMPATIBILITY 'B'; 
\c proto_test_db 
CREATE USER proto_test WITH PASSWORD 'Proto_test123'; 
SELECT set_native_password('proto_test', 'Proto_test123');
Enter fullscreen mode Exit fullscreen mode

Enable Dolphin Database Protocol Parameters

gs_guc set -N all -I all -c "enable_dolphin_proto = on"
Enter fullscreen mode Exit fullscreen mode

Note: This is a POSTMASTER parameter and requires a restart to take effect.

Set MySQL Protocol Listening Port

Set the MySQL protocol listening port, dolphin_server_port. The port number must be different from the port number that GBase 8c itself listens on.

gs_guc set -N all -I all -c "dolphin_server_port = 3307"
Enter fullscreen mode Exit fullscreen mode

Note: This is a POSTMASTER parameter and requires a restart to take effect.

Set Default Database Instance Name

If multiple B compatibility databases exist in the database, set the default connected database instance name using dolphin.default_database_name.

alter database proto_test set dolphin.default_database_name = my_test;
Enter fullscreen mode Exit fullscreen mode

After setting up, you can connect to GBase 8c using the MySQL client with the corresponding username and password.

Notes

  • Before using the MySQL client to connect to GBase 8c, ensure that the listen_addresses configuration is correct and pg_hba allows connections from the MySQL client machine IP.
  • When connecting using the MySQL client, use the following format:
mysql -u [user_name] -p --port [dolphin_server_port] -h [GBase 8c_listen_address]
Enter fullscreen mode Exit fullscreen mode
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Terabox Video Player