123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- 1. In the [SQL Shell](https://console.materialize.com/), or your preferred SQL
- client connected to Materialize, use the [`CREATE CONNECTION`](/sql/create-connection/#ssh-tunnel)
- command to create an SSH tunnel connection:
- ```mzsql
- CREATE CONNECTION ssh_connection TO SSH TUNNEL (
- HOST '<SSH_BASTION_HOST>',
- PORT <SSH_BASTION_PORT>,
- USER '<SSH_BASTION_USER>'
- );
- ```
- - Replace `<SSH_BASTION_HOST>` and `<SSH_BASTION_PORT`> with the public IP address and port of the SSH bastion host you created [earlier](#b-optional-configure-network-security).
- - Replace `<SSH_BASTION_USER>` with the username for the key pair you created for your SSH bastion host.
- 1. Get Materialize's public keys for the SSH tunnel connection:
- ```mzsql
- SELECT * FROM mz_ssh_tunnel_connections;
- ```
- 1. Log in to your SSH bastion host and add Materialize's public keys to the `authorized_keys` file, for example:
- ```sh
- # Command for Linux
- echo "ssh-ed25519 AAAA...76RH materialize" >> ~/.ssh/authorized_keys
- echo "ssh-ed25519 AAAA...hLYV materialize" >> ~/.ssh/authorized_keys
- ```
- 1. Back in the SQL client connected to Materialize, validate the SSH tunnel connection you created using the [`VALIDATE CONNECTION`](/sql/validate-connection) command:
- ```mzsql
- VALIDATE CONNECTION ssh_connection;
- ```
- If no validation error is returned, move to the next step.
- 1. Use the [`CREATE SECRET`](/sql/create-secret/) command to securely store the password for the `materialize` MySQL user you created [earlier](#2-create-a-user-for-replication):
- ```mzsql
- CREATE SECRET mysqlpass AS '<PASSWORD>';
- ```
- For AWS IAM authentication, you must create a connection to AWS. See the [`CREATE CONNECTION`](/sql/create-connection/#aws) command for details.
- 1. Use the [`CREATE CONNECTION`](/sql/create-connection/) command to create another connection object, this time with database access and authentication details for Materialize to use:
- ```mzsql
- CREATE CONNECTION mysql_connection TO MYSQL (
- HOST '<host>',
- SSH TUNNEL ssh_connection
- );
- ```
- - Replace `<host>` with your MySQL endpoint.
- AWS IAM authentication is also available, see the [`CREATE CONNECTION`](/sql/create-connection/#mysql)
- command for details.
- 1. Use the [`CREATE SOURCE`](/sql/create-source/) command to connect Materialize to your MySQL instance and start ingesting data:
- ```mzsql
- CREATE SOURCE mz_source
- FROM mysql CONNECTION mysql_connection
- FOR ALL TABLES;
- ```
- - By default, the source will be created in the active cluster; to use a
- different cluster, use the `IN CLUSTER` clause.
- - To ingest data from specific schemas or tables, use the `FOR SCHEMAS
- (<schema1>,<schema2>)` or `FOR TABLES (<table1>, <table2>)` options
- instead of `FOR ALL TABLES`.
- - To handle unsupported data types, use the `TEXT COLUMNS` or `IGNORE
- COLUMNS` options. Check out the [reference documentation](/sql/create-source/mysql/#supported-types)
- for guidance.
|