MySQL

Supported Versions

  • 8.0
  • 5.7
  • 5.6
  • 5.5
  • 5.1

Drivers

MySQL (for MySQL 5.5 and newer) MariaDB (for MySQL 5.1)
URL format jdbc:mysql://host:port/database jdbc:mysql://host:port/database
SSL support Yes - add ?useSsl=true Yes - add ?useSsl=true
Ships with MigrateDB Command-line No Yes
Maven Central coordinates mysql:mysql-connector-java:8.0.12 org.mariadb.jdbc:mariadb-java-client:2.3.0
Supported versions 5.1.44 and later 2.0.0 and later
Default Java class com.mysql.jdbc.Driver org.mariadb.jdbc.Driver

Compatibility

  • If a MySQL driver is not present on the project classpath, MariaDB will be used as a fallback driver. If this is not desired, add disableMariaDbDriver to your database URL.

SQL Script Syntax

  • Standard SQL syntax with statement delimiter ;
  • Delimiter change for stored procedures using DELIMITER statements
  • Comment directives generated by mysqldump (/!…/;)
  • MySQL-style single-line comments (# Comment)

Compatibility

  • DDL exported by mysqldump can be used unchanged in a MigrateDB migration.
  • Any MySQL SQL script executed by MigrateDB, can be executed by the MySQL command-line tool and other MySQL-compatible tools (after the placeholders have been replaced).

Example

/* Single line comment */
CREATE TABLE test_data (
 value VARCHAR(25) NOT NULL,
 PRIMARY KEY(value)
);

/*
Multi-line
comment
*/

-- MySQL procedure
DELIMITER //
CREATE PROCEDURE AddData()
 BEGIN
   # MySQL-style single line comment
   INSERT INTO test_data (value) VALUES ('Hello');
 END //
DELIMITER;

CALL AddData();

-- MySQL comments directives generated by mysqlsump
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;

-- Placeholder
INSERT INTO ${tableName} (value) VALUES ('Mr. T');

Authentication

MigrateDB supports the following MySQL authentication methods:

  • MySQL Option Files

Option Files

A username and password can be retrieved from MySQL option files for authentication, in which case they do not need to be supplied in configuration. The following table lists which option files are searched for per operating system, in order.

Windows   Other
%WINDIR%\my.ini, %WINDIR%\my.cnf   /etc/my.cnf
C:\my.ini, C:\my.cnf   /etc/mysql/my.cnf
%MYSQL_HOME%\my.ini, %MYSQL_HOME%\my.cnf   $MYSQL_HOME/my.cnf
%APPDATA%\MySQL\.mylogin.cnf   ~/.my.cnf
    ~/.mylogin.cnf

You can read more about MySQL option files here.

Limitations

  • No support for option file inclusions
  • No support for loading properties other than user and password from option files

Aurora MySQL ➡️