Skip to main content

MySQL

Airbyte's certified MySQL connector offers the following features:

  • Multiple methods of keeping your data fresh, including Change Data Capture (CDC) using the binlog.
  • All available sync modes, providing flexibility in how data is delivered to your destination.
  • Reliable replication at any table size with checkpointing and chunking of database reads.

The contents below include a 'Quick Start' guide, advanced setup steps, and reference information (data type mapping and changelogs).

Please note the minimum required platform version is v0.58.0 to run source-mysql 3.4.0.

Airbyte MySQL Connection

Quick Start

Here is an outline of the minimum required steps to configure a MySQL connector:

  1. Create a dedicated read-only MySQL user with permissions for replicating data
  2. Create a new MySQL source in the Airbyte UI using CDC logical replication
  3. (Airbyte Cloud Only) Allow inbound traffic from Airbyte IPs

Once this is complete, you will be able to select MySQL as a source for replicating data.

Step 1: Create a dedicated read-only MySQL user

These steps create a dedicated read-only user for replicating data. Alternatively, you can use an existing MySQL user in your database.

The following commands will create a new user:

CREATE USER <user_name> IDENTIFIED BY 'your_password_here';

Now, provide this user with read-only access to relevant schemas and tables:

GRANT SELECT, RELOAD, SHOW DATABASES, REPLICATION SLAVE, REPLICATION CLIENT ON *.* TO <user_name>;

If choosing to run using the STANDARD replication method (not recommended), only the SELECT permission is required.

Step 2: Enable binary logging on your MySQL server

You must enable binary logging for MySQL replication using CDC. Most cloud providers (AWS, GCP, etc.) provide easy one-click options for enabling the binlog on your source MySQL database.

If you are self-managing your MySQL server, configure your MySQL server configuration file with the following properties:

Configuring MySQL server config files to enable binlog
server-id                  = 223344
log_bin = mysql-bin
binlog_format = ROW
binlog_row_image = FULL
binlog_expire_logs_seconds = 864000
  • server-id : The value for the server-id must be unique for each server and replication client in the MySQL cluster. The server-id should be a non-zero value. If the server-id is already set to a non-zero value, you don't need to make any change. You can set the server-id to any value between 1 and 4294967295. For more information refer mysql doc
  • log_bin : The value of log_bin is the base name of the sequence of binlog files. If the log_bin is already set, you don't need to make any change. For more information refer mysql doc
  • binlog_format : The binlog_format must be set to ROW. For more information refer mysql doc
  • binlog_row_image : The binlog_row_image must be set to FULL. It determines how row images are written to the binary log. For more information refer mysql doc
  • binlog_expire_logs_seconds : This is the number of seconds for automatic binlog file removal. We recommend 864000 seconds (10 days) so that in case of a failure in sync or if the sync is paused, we still have some bandwidth to start from the last point in incremental sync. We also recommend setting frequent syncs for CDC.

Step 3: Create a new MySQL source in Airbyte UI

From your Airbyte Cloud or Airbyte Open Source account, select Sources from the left navigation bar, search for MySQL, then create a new MySQL source.

Create an Airbyte source

To fill out the required information:

  1. Enter the hostname, port number, and name for your MySQL database.
  2. Enter the username and password you created in Step 1.
  3. Select an SSL mode. You will most frequently choose require or verify-ca. Both of these always require encryption. verify-ca also requires certificates from your MySQL database. See here to learn about other SSL modes and SSH tunneling.
  4. Select Read Changes using Binary Log (CDC) from available replication methods.

Step 4: (Airbyte Cloud Only) Allow inbound traffic from Airbyte IPs.

If you are on Airbyte Cloud, you will always need to modify your database configuration to allow inbound traffic from Airbyte IPs. You can find a list of all IPs that need to be allowlisted in our Airbyte Security docs.

Now, click Set up source in the Airbyte UI. Airbyte will now test connecting to your database. Once this succeeds, you've configured an Airbyte MySQL source!

MySQL Replication Modes

Change Data Capture (CDC)

Airbyte uses logical replication of the MySQL binlog to incrementally capture deletes. To learn more how Airbyte implements CDC, refer to Change Data Capture (CDC). We generally recommend configure your MySQL source with CDC whenever possible, as it provides:

  • A record of deletions, if needed.
  • Scalable replication to large tables (1 TB and more).
  • A reliable cursor not reliant on the nature of your data. For example, if your table has a primary key but doesn't have a reasonable cursor field for incremental syncing (i.e. updated_at), CDC allows you to sync your table incrementally.

Standard

Airbyte offers incremental replication using a custom cursor available in your source tables (e.g. updated_at). We generally recommend against this replication method, but it is well suited for the following cases:

  • Your MySQL server does not expose the binlog.
  • Your data set is small, and you just want snapshot of your table in the destination.

Connecting with SSL or SSH Tunneling

SSL Modes

Airbyte Cloud uses SSL by default. You are not permitted to disable SSL while using Airbyte Cloud.

Here is a breakdown of available SSL connection modes:

  • disable to disable encrypted communication between Airbyte and the source
  • allow to enable encrypted communication only when required by the source
  • prefer to allow unencrypted communication only when the source doesn't support encryption
  • require to always require encryption. Note: The connection will fail if the source doesn't support encryption.
  • verify-ca to always require encryption and verify that the source has a valid SSL certificate
  • verify-full to always require encryption and verify the identity of the source

Connection via SSH Tunnel

You can connect to a MySQL server via an SSH tunnel.

When using an SSH tunnel, you are configuring Airbyte to connect to an intermediate server (also called a bastion or a jump server) that has direct access to the database. Airbyte connects to the bastion and then asks the bastion to connect directly to the server.

To connect to a MySQL server via an SSH tunnel:

  1. While setting up the MySQL source connector, from the SSH tunnel dropdown, select:
    • SSH Key Authentication to use a private as your secret for establishing the SSH tunnel
    • Password Authentication to use a password as your secret for establishing the SSH Tunnel
  2. For SSH Tunnel Jump Server Host, enter the hostname or IP address for the intermediate (bastion) server that Airbyte will connect to.
  3. For SSH Connection Port, enter the port on the bastion server. The default port for SSH connections is 22.
  4. 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.
  5. 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.
    • 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.

Generating a private key for SSH Tunneling

The connector expects an RSA key in PEM format. To generate this key:

ssh-keygen -t rsa -m PEM -f myuser_rsa

This produces the private key in pem format, and the public key remains in the standard format used by the authorized_keys file on your bastion host. The public key should be added to your bastion host to whichever user you want to use with Airbyte. The private key is provided via copy-and-paste to the Airbyte connector configuration screen, so it may log in to the bastion.

Limitations & Troubleshooting

To see connector limitations, or troubleshoot your MySQL connector, see more in our MySQL troubleshooting guide.

Data Type Mapping

MySQL data types are mapped to the following data types when synchronizing data. You can check test example values here. If you can't find the data type you are looking for, feel free to add a new test. If you do not see a type in this list, assume that it is coerced into a string. We are happy to take feedback on preferred mappings.

Any database or table encoding combination of charset and collation is supported. Charset setting however will not be carried over to destination and data will be encoded with whatever is configured by the destination. Please note that byte arrays are not yet supported.

MySQL Data Type Mapping
MySQL TypeResulting TypeNotes
bit(1)boolean
bit(>1)base64 binary string
booleanboolean
tinyint(1)boolean
tinyint(>1)number
tinyint(>=1) unsignednumber
smallintnumber
mediumintnumber
intnumber
bigintnumber
floatnumber
doublenumber
decimalnumber
binarystring
blobstring
datestringISO 8601 date string. ZERO-DATE value will be converted to NULL. If column is mandatory, convert to EPOCH.
datetime, timestampstringISO 8601 datetime string. ZERO-DATE value will be converted to NULL. If column is mandatory, convert to EPOCH.
timestringISO 8601 time string. Values are in range between 00:00:00 and 23:59:59.
yearyear stringDoc
char, varchar with non-binary charsetstring
tinyblobbase64 binary string
blobbase64 binary string
mediumblobbase64 binary string
longblobbase64 binary string
binarybase64 binary string
varbinarybase64 binary string
tinytextstring
textstring
mediumtextstring
longtextstring
jsonserialized json stringE.g. {"a": 10, "b": 15}
enumstring
setstringE.g. blue,green,yellow
geometrybase64 binary string

Changelog

Expand to review
VersionDatePull RequestSubject
3.6.22024-07-1742087Adding more error translations for MySql source.
3.6.12024-07-1942122Improve wass error message + logging.
3.6.02024-07-1740208Start using the new error MySql source error handler that comes with a new error translation layer.
3.5.12024-07-1742043Adopt latest CDK + fixes.
3.5.02024-07-1138240Implement WASS.
3.4.122024-07-0140516Remove dbz heartbeat.
3.4.112024-06-2640561Support PlanetScale MySQL's per-query row limit.
3.4.102024-06-1439349Full refresh stream sending internal count metadata.
3.4.92024-06-1139405Adopt latest CDK.
3.4.82024-06-0539144Upgrade Debezium to 2.5.4
3.4.72024-05-2938584Set is_resumable flag in discover.
3.4.62024-05-2938538Exit connector when encountering a config error.
3.4.52024-05-2338198Sync sending trace status messages indicating progress.
3.4.42024-05-1538208disable counts in full refresh stream in state message.
3.4.32024-05-1338104Handle transient error messages.
3.4.22024-05-0738046Resumeable refresh should run only if there is source defined pk.
3.4.12024-05-0337824Fixed a bug on Resumeable full refresh where cursor based source throw NPE.
3.4.02024-05-0236932Resumeable full refresh. Note please upgrade your platform - minimum platform version is 0.58.0.
3.3.252024-05-0237781Adopt latest CDK.
3.3.242024-05-0137742Adopt latest CDK. Remove Debezium retries.
3.3.232024-04-2337507Better errors when user switches from CDC to non-CDC mode.
3.3.222024-04-2237541Adopt latest CDK. reduce excessive logs.
3.3.212024-04-2237476Adopt latest CDK.
3.3.202024-04-1637111Populate null values in record message.
3.3.192024-04-1537328Populate airbyte_meta.changes
3.3.182024-04-1537324Refactor source operations.
3.3.172024-04-1036919Fix a bug in conversion of null values.
3.3.162024-04-0536872Update to connector's metadat definition.
3.3.152024-04-0536577Config error will not send out system trace message
3.3.142024-04-0436742To use new kotlin CDK
3.3.132024-02-2935529Refactor state iterator messages.
3.3.122024-02-2735675Fix invalid cdc error message.
3.3.112024-02-2335527Adopt 0.23.1 and shutdown timeouts.
3.3.102024-02-2235569Fix logging bug.
3.3.92024-02-2135525Adopt 0.21.4 and reduce cdc state compression threshold to 1MB.
3.3.82024-02-2035338Add config to throw an error on invalid CDC position.
3.3.72024-02-1335036Emit analytics message for invalid CDC cursor.
3.3.62024-02-1334869Don't emit state in SourceStateIterator when there is an underlying stream failure.
3.3.52024-02-1234580Support special chars in db name
3.3.42024-02-0834750Adopt CDK 0.19.0
3.3.32024-01-2634573Adopt CDK v0.16.0.
3.3.22024-01-0833005Adding count stats for incremental sync in AirbyteStateMessage
3.3.12024-01-0333312Adding count stats in AirbyteStateMessage
3.3.02023-12-1933436Remove LEGACY state flag
3.2.42023-12-1233356Support for better debugging tools..
3.2.32023-12-0833210Update MySql driver property value for zero date handling.
3.2.22023-12-0633082Improvements to MySQL schema snapshot error handling.
3.2.12023-11-2832610Support initial syncs using binary as primary key.
3.2.02023-11-2931062enforce SSL on Airbyte Cloud
3.1.92023-11-2732662Apply initial setup time to debezium engine warmup time.
3.1.82023-11-2232656Adopt java CDK version 0.5.0.
3.1.72023-11-0832125fix compilation warnings
3.1.62023-11-0632193Adopt java CDK version 0.4.1.
3.1.52023-10-3132024Upgrade to Debezium version 2.4.0.
3.1.42023-10-3031960Adopt java CDK version 0.2.0.
3.1.32023-10-1131322Correct pevious release
3.1.22023-09-2930806Cap log line length to 32KB to prevent loss of records
3.1.12023-09-2630744Update MySQL JDBC connection configs to keep default auto-commit behavior
3.1.02023-09-2130270Enhanced Standard Sync with initial load via Primary Key with a switch to cursor for incremental syncs
3.0.92023-09-2030620Airbyte Certified MySQL Source connector
3.0.82023-09-1430333CDC : Update the correct timezone parameter passed to Debezium to database.connectionTimezone
3.0.72023-09-1330375Fix a bug causing a failure when DB views are included in sync
3.0.62023-09-1230308CDC : Enable compression of schema history blob in state
3.0.52023-09-1230289CDC : Introduce logic for compression of schema history blob in state
3.0.42023-09-0630213CDC : Checkpointable initial snapshot
3.0.32023-08-3129821Set replication_method display_type to radio
3.0.22023-08-3030015Logging : Log storage engines associated with tables in the sync
3.0.12023-08-2129308CDC: Enable frequent state emissions during incremental runs
3.0.02023-08-0828756CDC: Set a default cursor
2.1.22023-08-0829220Add indicator that CDC is the recommended update method
2.1.12023-07-3128882Improve replication method labels and descriptions
2.1.02023-06-2627737License Update: Elv2
2.0.252023-06-2027212Fix silent exception swallowing in StreamingJdbcDatabase
2.0.242023-05-2526473CDC : Limit queue size
2.0.232023-05-2425586No need to base64 encode strings on databases sorted with binary collation
2.0.222023-05-2225859Allow adding sessionVariables JDBC parameters
2.0.212023-05-1025460Handle a decimal number with 0 decimal points as an integer
2.0.202023-05-0125740Disable index logging
2.0.192023-04-2625401CDC : Upgrade Debezium to version 2.2.0
2.0.182023-04-1925345Logging : Log database indexes per stream
2.0.172023-04-1924582CDC : refactor for performance improvement
2.0.162023-04-1725220Logging changes : Log additional metadata & clean up noisy logs
2.0.152023-04-1225131Make Client Certificate and Client Key always show
2.0.142023-04-1124656CDC minor refactor
2.0.132023-04-0624820Fix data loss bug during an initial failed non-CDC incremental sync
2.0.122023-04-0424833Fix Debezium retry policy configuration
2.0.112023-03-2824166Fix InterruptedException bug during Debezium shutdown
2.0.102023-03-2724529Preparing the connector for CDC checkpointing
2.0.92023-03-2424529Set SSL Mode to required on strict-encrypt variant
2.0.82023-03-2220760Removed redundant date-time datatypes formatting
2.0.72023-03-2124207Fix incorrect schema change warning in CDC mode
2.0.62023-03-2123984Support CDC heartbeats
2.0.52023-03-2124147Fix error with CDC checkpointing
2.0.42023-03-2024147Support different table structure during "DESCRIBE" query
2.0.32023-03-1524082Fixed NPE during cursor values validation
2.0.22023-03-1423908Log warning on null cursor values
2.0.12023-03-1023939For network isolation, source connector accepts a list of hosts it is allowed to connect
2.0.02023-03-0623112Upgrade Debezium version to 2.1.2
1.0.212023-01-2520939Adjust batch selection memory limits databases.
1.0.202023-01-2420593Handle ssh time out exception
1.0.192022-12-1420436Consolidate date/time values mapping for JDBC sources
1.0.182022-12-1420378Improve descriptions
1.0.172022-12-1320289Mark unknown column exception as config error
1.0.162022-12-1218959CDC : Don't timeout if snapshot is not complete.
1.0.152022-12-0620000Add check and better messaging when user does not have permission to access binary log in CDC mode
1.0.142022-11-2219514Adjust batch selection memory limits databases.
1.0.132022-11-1418956Clean up Tinyint Unsigned data type identification
1.0.122022-11-0719025Stop enforce SSL if ssl mode is disabled
1.0.112022-11-0318851Fix bug with unencrypted CDC connections
1.0.102022-11-0218619Fix bug with handling Tinyint(1) Unsigned values as boolean
1.0.92022-10-3118538Encode database name
1.0.82022-10-2518383Better SSH error handling + messages
1.0.72022-10-2118263Fixes bug introduced in 15833 and adds better error messaging for SSH tunnel in Destinations
1.0.62022-10-1918087Better error messaging for configuration errors (SSH configs, choosing an invalid cursor)
1.0.52022-10-1718041Fixes bug introduced 2022-09-12 with SshTunnel, handles iterator exception properly
2022-10-1315535Update incremental query to avoid data missing when new data is inserted at the same time as a sync starts under non-CDC incremental mode
1.0.42022-10-1117815Expose setting server timezone for CDC syncs
1.0.32022-10-0717236Fix large table issue by fetch size
1.0.22022-10-0317170Make initial CDC waiting time configurable
1.0.12022-10-0117459Upgrade debezium version to 1.9.6 from 1.9.2
1.0.02022-09-2717164Certify MySQL Source as Beta
0.6.152022-09-2717299Improve error handling for strict-encrypt mysql source
0.6.142022-09-2616954Implement support for snapshot of new tables in CDC mode
0.6.132022-09-1415668Wrap logs in AirbyteLogMessage
0.6.122022-09-1316657Improve CDC record queueing performance
0.6.112022-09-0816202Adds error messaging factory to UI
0.6.102022-09-0816007Implement per stream state support.
0.6.92022-09-0316216Standardize spec for CDC replication. See upgrade instructions above.
0.6.82022-09-0116259Emit state messages more frequently
0.6.72022-08-3016114Prevent traffic going on an unsecured channel in strict-encryption version of source mysql
0.6.62022-08-2515993Improved support for connecting over SSL
0.6.52022-08-2515917Fix temporal data type default value bug
0.6.42022-08-1814356DB Sources: only show a table can sync incrementally if at least one column can be used as a cursor field
0.6.32022-08-1215044Added the ability to connect using different SSL modes and SSL certificates
0.6.22022-08-1115538Allow additional properties in db stream state
0.6.12022-08-0214801Fix multiple log bindings
0.6.02022-07-2614362Integral columns are now discovered as int64 fields.
0.5.172022-07-2214714Clarified error message when invalid cursor column selected
0.5.162022-07-1414574Removed additionalProperties:false from JDBC source connectors
0.5.152022-06-2314077Use the new state management
0.5.132022-06-2113945Aligned datatype test
0.5.122022-06-1713864Updated stacktrace format for any trace message errors
0.5.112022-05-0312544Prevent source from hanging under certain circumstances by adding a watcher for orphaned threads.
0.5.102022-04-2912480Query tables with adaptive fetch size to optimize JDBC memory consumption
0.5.92022-04-0611729Bump mina-sshd from 2.7.0 to 2.8.0
0.5.62022-02-2110242Fixed cursor for old connectors that use non-microsecond format. Now connectors work with both formats
0.5.52022-02-1810242Updated timestamp transformation with microseconds
0.5.42022-02-1110251bug Source MySQL CDC: sync failed when has Zero-date value in mandatory column
0.5.22021-12-146425MySQL CDC sync fails because starting binlog position not found in DB
0.5.12021-12-138582Update connector fields title/description
0.5.02021-12-117970Support all MySQL types
0.4.132021-12-038335Source-MySql: do not check cdc required param binlog_row_image for standard replication
0.4.122021-12-018371Fixed incorrect handling "\n" in ssh key
0.4.112021-11-198047Source MySQL: transform binary data base64 format
0.4.102021-11-157820Added basic performance test
0.4.92021-11-027559Correctly process large unsigned short integer values which may fall outside java's Short data type capability
0.4.82021-09-166093Improve reliability of processing various data types like decimals, dates, datetime, binary, and text
0.4.72021-09-306585Improved SSH Tunnel key generation steps
0.4.62021-09-296510Support SSL connection
0.4.52021-09-176146Added option to connect to DB via SSH
0.4.12021-07-234956Fix log link
0.3.72021-06-093179Add AIRBYTE_ENTRYPOINT for Kubernetes support
0.3.62021-06-093966Fix excessive logging for CDC method
0.3.52021-06-073890Fix CDC handle tinyint(1) and boolean types
0.3.42021-06-043846Fix max integer value failure
0.3.32021-06-023789MySQL CDC poll wait 5 minutes when not received a single record
0.3.22021-06-013757MySQL CDC poll 5s to 5 min
0.3.12021-06-013505Implemented MySQL CDC
0.3.02021-04-212990Support namespaces
0.2.52021-04-152899Fix bug in tests
0.2.42021-03-282600Add NCHAR and NVCHAR support to DB and cursor type casting
0.2.32021-03-262611Add an optional jdbc_url_params in parameters
0.2.22021-03-262460Destination supports destination sync mode
0.2.12021-03-182488Sources support primary keys
0.2.02021-03-092238Protocol allows future/unknown properties
0.1.102021-02-021887Migrate AbstractJdbcSource to use iterators
0.1.92021-01-251746Fix NPE in State Decorator
0.1.82021-01-191724Fix JdbcSource handling of tables with same names in different schemas
0.1.72021-01-141655Fix JdbcSource OOM
0.1.62021-01-081307Migrate Postgres and MySQL to use new JdbcSource
0.1.52020-12-111267Support incremental sync
0.1.42020-11-301046Add connectors using an index YAML file