MySQL
This connector materializes Flow collections into tables in a MySQL database.
It is available for use in the Flow web application. For local development or
open-source workflows,
ghcr.io/estuary/materialize-mysql:dev
provides the latest version of the connector as a Docker image. You can also follow the link in your browser to see past image versions.
Prerequisites
To use this connector, you'll need:
- A MySQL database to which to materialize, and user credentials.
- MySQL versions 5.7 and later are supported
- The connector will create new tables in the database per your specification, so user credentials must have access to create new tables.
- The
local_infile
global variable must be enabled. You can enable this setting by runningSET GLOBAL local_infile = true
in your database.
- At least one Flow collection
Setup
To meet these requirements, follow the steps for your hosting type.
In addition to standard MySQL, this connector supports cloud-based MySQL instances. Google Cloud Platform, Amazon Web Service, and Microsoft Azure are currently supported. You may use other cloud platforms, but Estuary doesn't guarantee performance.
To connect securely, you can either enable direct access for Flows's IP or use an SSH tunnel.
Azure Database for MySQL
You must configure your database to allow connections from Estuary. There are two ways to do this: by granting direct access to Flow's IP or by creating an SSH tunnel.
-
Connect Directly With Azure Database For MySQL: Create a new firewall rule that grants access to the Estuary Flow IP addresses
-
Connect With SSH Tunneling: Follow the instructions for setting up an SSH connection to Azure Database.
Configuration
To use this connector, begin with data in one or more Flow collections. Use the below properties to configure a MySQL materialization, which will direct one or more of your Flow collections to your desired tables, or views, in the database.
Properties
Endpoint
Property | Title | Description | Type | Required/Default |
---|---|---|---|---|
/database | Database | Name of the logical database to materialize to. | string | Required |
/address | Address | Host and port of the database. If only the host is specified, port will default to 3306 . | string | Required |
/password | Password | Password for the specified database user. | string | Required |
/user | User | Database user to connect as. | string | Required |
/timezone | Timezone | Timezone to use when materializing datetime columns. Should normally be left blank to use the database's 'time_zone' system variable. Only required if the 'time_zone' system variable cannot be read. Must be a valid IANA time zone name or +HH:MM offset. Takes precedence over the 'time_zone' system variable if both are set. | string | |
/advanced | Advanced Options | Options for advanced users. You should not typically need to modify these. | object | |
/advanced/sslmode | SSL Mode | Overrides SSL connection behavior by setting the 'sslmode' parameter. | string | |
/advanced/ssl_server_ca | SSL Server CA | Optional server certificate authority to use when connecting with custom SSL mode | string | |
/advanced/ssl_client_cert | SSL Client Certificate | Optional client certificate to use when connecting with custom SSL mode. | string | |
/advanced/ssl_client_key | SSL Client Key | Optional client key to use when connecting with custom SSL mode. | string |
Setting the MySQL time zone
MySQL's time_zone
server system variable is set to SYSTEM
by default.
If you intend to materialize collections including fields of with format: date-time
or format: time
,
and time_zone
is set to SYSTEM
,
Flow won't be able to detect the time zone and convert datetimes to the
appropriate timezone when materializing.
To avoid this, you must explicitly set the time zone for your database.
You can:
-
Specify a numerical offset from UTC.
- For MySQL version 8.0.19 or higher, values from
-13:59
to+14:00
, inclusive, are permitted. - Prior to MySQL 8.0.19, values from
-12:59
to+13:00
, inclusive, are permitted
- For MySQL version 8.0.19 or higher, values from
-
Specify a named timezone in IANA timezone format.
-
If you're using Amazon Aurora, create or modify the DB cluster parameter group associated with your MySQL database. Set the
time_zone
parameter to the correct value.
For example, if you're located in New Jersey, USA, you could set time_zone
to -05:00
or -04:00
, depending on the time of year.
Because this region observes daylight savings time, you'd be responsible for changing the offset.
Alternatively, you could set time_zone
to America/New_York
, and time changes would occur automatically.
If using IANA time zones, your database must include time zone tables. Learn more in the MySQL docs.
If you are unable to set the time_zone
in the database and need to materialize
collections with date-time or time fields, the materialization can be configured
to assume a time zone using the timezone
configuration property (see above). The timezone
configuration property can be set as a numerical offset or IANA timezone format.
SSL Mode
Possible values:
disabled
: A plain unencrypted connection is established with the serverpreferred
: Only use SSL connection if the server asks for itrequired
: Connect using an SSL connection, but do not verify the server's certificate.verify_ca
: Connect using an SSL connection, and verify the server's certificate against the given SSL Server CA, but does not verify the server's hostname. This option is most commonly used when connecting to an IP address which does not have a hostname to be verified. When using this mode, SSL Server CA must be provided.verify_identity
: Connect using an SSL connection, verify the server's certificate and the server's hostname. This is the most secure option. When using this mode, SSL Server CA must be provided.
Optionally, SSL Client Certificate and Key can be provided if necessary to authorize the client.
Bindings
Property | Title | Description | Type | Required/Default |
---|---|---|---|---|
/table | Table | Table name to materialize to. It will be created by the connector, unless the connector has previously created it. | string | Required |
/delta_updates | Delta Update | Should updates to this table be done via delta updates. | boolean | false |
Sample
materializations:
${PREFIX}/${mat_name}:
endpoint:
connector:
image: ghcr.io/estuary/materialize-mysql:dev
config:
database: flow
address: localhost:5432
password: flow
user: flow
bindings:
- resource:
table: ${TABLE_NAME}
source: ${PREFIX}/${COLLECTION_NAME}
MySQL on managed cloud platforms
In addition to standard MySQL, this connector supports cloud-based MySQL instances. To connect securely, you can either enable direct access for Flows's IP or use an SSH tunnel.
Google Cloud Platform, Amazon Web Service, and Microsoft Azure are currently supported. You may use other cloud platforms, but Estuary doesn't guarantee performance.
Setup
You must configure your database to allow connections from Estuary. There are two ways to do this: by granting direct access to Flow's IP or by creating an SSH tunnel.
-
Connect directly with Amazon RDS or Amazon Aurora: Edit the VPC security group associated with your database instance, or create a new VPC security group and associate it with the database instance.
-
Modify the instance, choosing Publicly accessible in the Connectivity settings.
-
Per the steps in the Amazon documentation, create a new inbound rule and a new outbound rule that allow all traffic from the IP addresses ``.
-
-
Connect directly with Google Cloud SQL: Enable public IP on your database and add Estuary Flow IP addresses as authorized IP addresses. See the instructions below to use SSH Tunneling instead of enabling public access.
-
Connect with SSH tunneling
-
Refer to the guide to configure an SSH server on the cloud platform of your choice.
-
Configure your connector as described in the configuration section above, with the additional of the
networkTunnel
stanza to enable the SSH tunnel, if using. See Connecting to endpoints on secure networks for additional details and a sample.
-
To configure the connector, you must specify the database address in the format
host:port
. (You can also supply host
only; the connector will use the port 3306
by default, which is correct in many cases.)
You can find the host and port in the following locations in each platform's console:
- Amazon RDS and Amazon Aurora: host as Endpoint; port as Port.
- Google Cloud SQL: host as Private IP Address; port is always
3306
. You may need to configure private IP on your database. - Azure Database: host as Server Name; port under Connection Strings (usually
3306
).
Delta updates
This connector supports both standard (merge) and delta updates. The default is to use standard updates.