Load data from MySQL

This article explains how to connect to a MySQL database with Exasol and then load data.

To view details about data type mappings or to migrate data, see the MySQL to Exasol migration script in our GitHub repository.

Prerequisites

  • The MySQL server must be reachable from the Exasol system.

  • The user credentials in the connection must be valid.

Download driver

Download the JDBC driver for MySQL from the MySQL Connectors page. In the Select Operating System dropdown menu, select Platform Independent.

Add JDBC driver

To add the JDBC driver, create a configuration file called settings.cfg with the following settings:

DRIVERNAME=MySQL
PREFIX=jdbc:mysql:
FETCHSIZE=100000
INSERTSIZE=-1
NOSECURITY=YES

Follow the procedure described in Add JDBC Driver to upload the settings.cfg configuration and JDBC driver files to Exasol.

Create connection

To create a connection, run the following statement. Replace the connection string and credentials as needed.

The MySQL user must have enough privileges to create a connection.

CREATE OR REPLACE CONNECTION JDBC_MYSQL
    TO 'jdbc:mysql://192.168.99.100:3306/my_database' 
    USER 'user_name'
    IDENTIFIED BY 'my_password';

To test the connection, run the following statement.

select * from 
(
import from JDBC at JDBC_MYSQL
statement 'select ''Connection works'' from dual'
);

Load data

You can use the IMPORT statement to load data using the connection you created above. IMPORT supports loading data from a table or a SQL statement.