MySQL
Overview
This page contains the setup guide and reference information for the MySQL source connector.
Features
Feature | Supported | Notes |
---|---|---|
Full Refresh Sync | Yes | |
Incremental - Append Sync | Yes | |
CDC | Yes | |
SSL Support | Yes | |
SSH Tunnel Connection | Yes | |
Arrays | Yes | Byte arrays are not supported yet |
Data type mapping
MySQL Type | Resulting Type | Notes |
---|---|---|
bit(1) | boolean | |
bit(>1) | base64 binary string | |
boolean | boolean | |
tinyint(1) | boolean | |
tinyint(>1) | float | |
tinyint(>=1) unsigned | float | |
smallint | float | |
mediumint | float | |
int | float | |
bigint | float | |
float | float | |
double | float | |
decimal | float | |
binary | string | |
blob | string | |
date | string | ISO 8601 date string. ZERO-DATE value will be converted to NULL. If column is mandatory, convert to EPOCH. |
datetime , timestamp | string | ISO 8601 datetime string. ZERO-DATE value will be converted to NULL. If column is mandatory, convert to EPOCH. |
time | string | ISO 8601 time string. Values are in range between 00:00:00 and 23:59:59. |
year | year string | MySQL Docs (opens in a new tab) |
char , varchar with non-binary charset | string | |
char , varchar with binary charset | base64 binary string | |
tinyblob | base64 binary string | |
blob | base64 binary string | |
mediumblob | base64 binary string | |
longblob | base64 binary string | |
binary | base64 binary string | |
varbinary | base64 binary string | |
tinytext | string | |
text | string | |
mediumtext | string | |
longtext | string | |
json | serialized json string | E.g. {"a": 10, "b": 15} |
enum | string | |
set | string | E.g. blue,green,yellow |
geometry | base64 binary string |
If a specific type isn't mentioned in this list, it's typically converted into a string.
Getting started
Requirements and prerequisites
For utilizing the MySQL source, ensure you have the following:
- MySQL Server version 8.0, 5.7, or 5.6.
- Establishment of a dedicated read-only user account that can access all tables necessary for replication.
- Ensure Y42 can access your database. This requirement depends on your network configuration. We suggest adding Y42's production IP addresses, to your whitelist.
Set up guide
Step 1: (Optional, but recommended) Create a dedicated read-only user
This stage is optional but strongly suggested to allow better permission management and auditing.
- To create a dedicated database user, execute the following commands on your database:
_10CREATE USER 'y42'@'%' IDENTIFIED BY 'your_password_here';
- The appropriate permissions vary between the
STANDARD
andCDC
replication methods. For theSTANDARD
replication method, only theSELECT
permission is needed._10GRANT SELECT ON <database name>.* TO 'y42'@'%'; - For
CDC
replication method,SELECT, RELOAD, SHOW DATABASES, REPLICATION SLAVE, REPLICATION CLIENT
permissions are required._10GRANT SELECT, RELOAD, SHOW DATABASES, REPLICATION SLAVE, REPLICATION CLIENT ON *.* TO 'y42'@'%';
- The appropriate permissions vary between the
Step 2: Set up the MySQL source
- Create a new source, select MySQL (Airbyte) from the Source type dropdown and enter a name for it.
- On the source setup page, create a new MySQL secret, enter a unique name for it.
- For the Host, Port, and DB Name, enter the hostname, port number, and name for your MySQL database.
- For User and Password, enter the username and password you created in Step 1.
- (Optional) If you want to use CDC replication select Logical Replication (CDC) as the replication method and enter the names of the replication slot and publication you created.
- (Optional) If you want to connect via SSH tunnel, select "SSH Tunnel Method": SSH Key Authentication or Password Authentication.
Step 3: (Optional) Setting up CDC based syncing
Binary logging is enabled by default since Mysql 8.0. For older versions make sure you have these parameters in your mysql server configuration:
_10server-id = 1 (any none-zero value)_10log_bin = mysql-bin_10binlog_format = ROW (default)_10binlog_row_image = FULL (default)_10binlog_expire_logs_seconds = 864000 (recommended minimum)
During the secret setup set the replication method to Logical Replication.
Step 4: (Optional) Connection via SSH Tunnel
In case of an SSH connection, select "SSH Tunnel Method" other than "No Tunnel" and configure SSH tunneling:
- For SSH Tunnel Jump Server Host, enter the hostname or IP address for the intermediate (bastion) server that Y42 will connect to.
- For SSH Connection Port, enter the port on the bastion server. The default port for SSH connections is 22.
- For SSH Login Username, enter the username to use when connecting to the bastion server. Note: This is the operating system username and not the MySQL username.
- For authentication:
- If you selected SSH Key Authentication, set the SSH Private Key to the private key that you are using to create the SSH connection.
To generate a private key for SSH Tunneling, execute the following command:
The command produces the private key in PEM format and the public key remains in the standard format used by the_10ssh-keygen -t rsa -m PEM -f myuser_rsa
authorized_keys
file on your bastion server. Add the public key to your bastion host to the user you want to use for data sync. The private key is provided via copy-and-paste to the configuration screen. - If you selected Password Authentication, enter the password for the operating system user to connect to the bastion server. Note: This is the operating system password and not the MySQL password.
- If you selected SSH Key Authentication, set the SSH Private Key to the private key that you are using to create the SSH connection.
To generate a private key for SSH Tunneling, execute the following command:
Troubleshooting
- Certain issues might arise when trying to map values from MySQL's datetime field to other relational databases. MySQL allows zero values for date/time as an alternative to
NULL
, which may not be compatible with other databases. To mitigate this issue, you can use the JDBC connector in the source setting and input the following key-value pair:zerodatetimebehavior=Converttonull
- A few users have encountered difficulties when trying to connect to Amazon RDS MySQL or MariaDB, indicated by the error message:
Cannot create a PoolableConnectionFactory
. To rectify this problem, includeenabledTLSProtocols=TLSv1.2
in the JDBC parameters. - Some users have reported an error when attempting to connect to Amazon RDS MySQL:
Error: HikariPool-1 - Connection is not available, request timed out after 30001ms.
Often, this issue stems from the VPC disallowing public traffic. Nevertheless, we suggest you go through the AWS RDS troubleshooting checklist (opens in a new tab) to ensure the appropriate permissions/settings have been granted for database connection.