Get your free Liquibase Fundamentals Certification!

Liquibase MySQL Database Support

  • 8.0 – Not tested
  • 5.7 – COMMUNITY TESTED
  • 5.6 – COMMUNITY TESTED
  • 5.5 – COMMUNITY TESTED

Learn how we define different types of support.

Supported Commands & Features

OperationCommunityProBusinessEnterprise
Update
— Deploy Native MySQL Scripts
Rollback
— Targeted Rollback
Snapshot/
GenerateChangelog
Diff/DiffChangelog
— Diff: JSON Output
Status/History
Rules
Packager
Forecast
Download CommunityTry Pro Free

Supported Objects

Object SupportCommunityProBusinessEnterprise
Tables
Views
Indexes
Constraints
SynonymsN/AN/AN/A
Sequences
Stored Logic
• Procedures
• Packages/
Package Body
• Functions
• Triggers
Procedure support onlyProcedure support only
Download CommunityTry Pro Free

Get Started

It’s easy to get started using Liquibase Community and Liquibase Pro for updating your MySQL databases. Contact us on how to get started with Liquibase Business or Enterprise.

1. Download Software

a. Download and install Liquibase Community. If you’d like to use Liquibase Pro, get a trial key or purchase Liquibase Pro.

b. Download the latest MySQL JDBC Driver for your system.

2. Configure Liquibase

a. Configure the liquibase.properties file.

# Database Short Name: mysql

# Path to the Liquibase changelog file that contains 
# your database changes (example in step #3 below)
changeLogFile=../path/to/file/changelog.xml

# JDBC Driver Configuration
driver=com.mysql.cj.jdbc.Driver
classpath=../Liquibase_Drivers/mysql-connector-java-8.0.20.jar

# Database Connection Configuration (access the database)
url=jdbc:mysql://localhost:3306/my_database
username=<db username>
password=<db password>

b. (optional) Configure Maven integration.

Maven

1. Configure the MySQL driver in the Maven POM file dependency section.

<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.liquibase</groupId>
    <artifactId>liquibase-example</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <dependencies>
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>8.0.21</version>
        </dependency>
    </dependencies>
</project>

2. Configure the Maven update goal for the Liquibase Maven plugin and reference the liquibase.properties file defined above in the Maven configuration.

<project>  
    <build>
      <plugins>
        <plugin>
           <groupId>org.liquibase</groupId>
           <artifactId>liquibase-maven-plugin</artifactId>
           <version>4.0.0</version>
           <configuration>
<propertyFile>./liquibase.properties</propertyFile>
           </configuration>
           <executions>
             <execution>
               <phase>process-resources</phase>
               <goals>
                 <goal>update</goal>
               </goals>
             </execution>
           </executions>
        </plugin>
      </plugins>
    </build>
</project>

3. Create the First Database Change

Create a changelog with the first database change.

XML
SQL

changelog.xml file

<?xml version="1.1" encoding="UTF-8" standalone="no"?>
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog" xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext" xmlns:pro="http://www.liquibase.org/xml/ns/pro" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd http://www.liquibase.org/xml/ns/pro http://www.liquibase.org/xml/ns/pro/liquibase-pro-4.0.xsd http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.0.xsd">
  <changeSet id="1" author="bob">
    <createTable tableName="department">  
      <column name="id" type="int">  
        <constraints primaryKey="true" nullable="false"/>  
      </column>  
      <column name="name" type="varchar(50)">  
        <constraints nullable="true"/>  
      </column>
    </createTable>  
  </changeSet>
</databaseChangeLog>

changelog.sql file

--liquibase formatted sql  

--changeset bob:1  
create table department2  (  
    id int primary key not null,  
    name varchar(50)
);

4. Run Example Command (update)

Run the Liquibase status and update commands to see the change applied to the database.

CLI
Maven

% liquibase status
Liquibase Community 3.10.0 by Datical
1 change sets have not been applied to testuser@172.17.0.1@jdbc:mysql://localhost:3306/testdb1
Liquibase command 'status' was executed successfully.

% liquibase update
Liquibase Community 3.10.0 by Datical
Liquibase: Update has been successful.

% liquibase status
Liquibase Community 3.10.0 by Datical
testuser@172.17.0.1@jdbc:mysql://localhost:3306/testdb1 is up to date
Liquibase command 'status' was executed successfully.

$ mvn liquibase:update
[INFO] Scanning for projects…
[INFO]
[INFO] -------< com.liquibase:liquibase-includeAll-changeLogDirectory >--------
[INFO] Building liquibase-includeAll-changeLogDirectory 0.0.1-SNAPSHOT
[INFO] -------------------[ jar ]--------------------
[INFO]
[INFO] --- liquibase-maven-plugin:4.0.0:update (default-cli) @ liquibase-includeAll-changeLogDirectory ---
[INFO] ----------------------------------------------
[INFO] Parsing Liquibase Properties File
[INFO] File: ./liquibase.properties
[INFO] 'classpath' in properties file is not being used by this task.
[INFO] ----------------------------------------------
[INFO]
[INFO]
[INFO] Liquibase Community 4.0.0 by Datical
[INFO] Starting Liquibase at 20:42:43 (version 4.0.0 #19 built at 2020-07-13 19:45+0000)
[INFO] Parsing Liquibase Properties File ./liquibase.properties for changeLog parameters
[INFO] Executing on Database: jdbc:mysql://localhost:3306/testdb1
Sep 28, 2020 8:42:44 PM liquibase.lockservice
INFO: Successfully acquired change log lock
Sep 28, 2020 8:42:44 PM liquibase.changelog
INFO: Reading from DATABASECHANGELOG
Sep 28, 2020 8:42:44 PM liquibase.changelog
INFO: Custom SQL executed
Sep 28, 2020 8:42:44 PM liquibase.changelog
INFO: ChangeSet ./changelog.sql::2::bob ran successfully in 24ms
Sep 28, 2020 8:42:44 PM liquibase.lockservice
INFO: Successfully released change log lock
[INFO] ---------------------------------------------
[INFO]
[INFO] ---------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ---------------------------------------------
[INFO] Total time: 1.578 s
[INFO] Finished at: 2020-09-28T20:42:44-05:00
[INFO] ---------------------------------------------

Liquibase Documentation

Articles by Community Contributors

Get Help