Overview

Use MySQL as a destination in Mage to write pipeline data into structured tables within a MySQL database. This integration supports both direct connections and SSH tunneling for secure access to remote or private databases.

Each record from the Mage pipeline is inserted as a row in the configured table. Mage supports optional connection customization and SSL settings through connection keyword arguments.


Configuration Parameters

You must provide the following parameters when configuring the MySQL destination:

KeyDescriptionExample ValueRequired
databaseName of the MySQL database where data will be written.demo
hostHostname or IP address of the MySQL server.mage.abc.us-west-2.rds.amazonaws.com
portPort number used by MySQL (typically 3306).3306
usernameUsername with permission to access the database and target schema.root
passwordPassword for the MySQL user.abc123...
tableName of the destination table that Mage will write to.dim_users_v1
connection_methodMethod used to connect to the MySQL server: direct or ssh_tunnel.direct or ssh_tunnel
ssh_host(Optional) Host of the bastion or jump server for SSH tunnel access.123.45.67.89
ssh_port(Optional) SSH port on the bastion host. Default is 22.22
ssh_username(Optional) SSH username for authentication.username
ssh_password(Optional) SSH password. Required if not using a private key.password
ssh_pkey(Optional) Path to or content of the private key file used for SSH authentication./path/to/private/key.pem
conn_kwargs(Optional) Additional MySQL connection parameters in dictionary format.{"ssl_ca": "CARoot.pem"}
use_lowercase(Optional) Whether to convert all column names to lowercase.true or false

Optional Configs

KeyDescriptionExample Value
skip_schema_creationIf true, Mage will skip running the CREATE SCHEMA command. Useful when the schema already exists. See related issuetrue
lower_caseIf true, all column names will be forced to lowercase. Default is true.true

Notes

  • For cloud-hosted MySQL (e.g., Amazon RDS, Azure Database for MySQL), ensure proper firewall rules and access control.
  • Use ssh_tunnel mode when connecting to databases hosted in private networks or VPCs.
  • The conn_kwargs parameter is useful for enabling SSL/TLS and advanced options (e.g., ssl_ca, ssl_cert, connect_timeout).
  • Mage automatically creates the destination table unless skip_schema_creation is set to true.