Back to Flyway

MariaDB

documentation/Reference/Database Driver Reference/MariaDB.md

latest3.4 KB
Original Source
  • Verified Versions: 5.1, 11.7
  • Maintainer: {% include redgate-badge.html %}

Supported Versions and Support Levels

{% include database-boilerplate.html %}

Driver

ItemDetails
URL format<code>jdbc:mysql://<i>host</i>:<i>port</i>/<i>database</i></code>
or
<code>jdbc:mariadb://<i>host</i>:<i>port</i>/<i>database</i></code>
SSL supportYes - add ?useSsl=true
Ships with Flyway Command-lineYes
Maven Central coordinatesorg.mariadb.jdbc:mariadb-java-client
Supported versions2.0.0 and later
Default Java classorg.mariadb.jdbc.Driver

Java Usage

MariaDB support is a separate dependency for Flyway and will need to be added to your Java project to access these features. MariaDB is found within the flyway-mysql plugin module.

Maven

Redgate

xml
<dependency>
    <groupId>com.redgate.flyway</groupId>
    <artifactId>flyway-mysql</artifactId>
</dependency>

Open Source

xml
<dependency>
    <groupId>org.flywaydb</groupId>
    <artifactId>flyway-mysql</artifactId>
</dependency>

Gradle

Redgate

groovy
buildscript {
    dependencies {
        implementation "com.redgate.flyway:flyway-mysql"
    }
}

Open Source

groovy
buildscript {
    dependencies {
        implementation "org.flywaydb:flyway-mysql"
    }
}

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 Flyway migration.
  • Any MySQL SQL script executed by Flyway, can be executed by the MySQL command-line tool and other MySQL-compatible tools (after the placeholders have been replaced).

Example

sql
/* 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} (name) VALUES ('Mr. T');