Command Line Interface
Liquibase can be run from the command line by running:
The command line migrator works well when you want to do migrations on demand, but don’t have Ant or Maven available such as on servers. The command line migrator also gives you more control over the process than the Servlet Listener, Ant or Maven do, allowing you to run maintenance commands like outputting SQL and listing/releasing database changelog locks.
Any values found after the command on the command line invocation will be considered a command parameter. The command line processor will validate whether the command line parameters are allowed for the current command. If the current command does not allow command line parameters or the parameter appears to be an incorrect format, then an error message of ‘unexpected command parameter’ will be logged and the execution will terminate.
The command line migrator also allows you to:
If you run the command line migrator without any arguments, you will get a help message listing all of your commands. See the following topics for a full list of commands:
If you do not want to always specify options on the command line, you can create a properties file that contains default values. By default, Liquibase will look for a file called
liquibase.properties in the current working directory, but you can specify an alternate location with the
--defaultsFile flag. If you have specified an option in a properties file and specify the same option on the command line, the value on the command line will override the properties file value.
Standard Update Run
Run update pulling changelogs from a .WAR file
Run update pulling changelogs from an .EAR file
Don’t execute changeSets, save SQL to /tmp/script.sql
List locks on the
Runs Liquibase using defaults from
Export Data from Database
This will export the data from the targeted database and put it in a folder “data” in a file name specified with <insert file name>.
Update passing changelog parameters
Add URL parameters useUnicode=true and characterEncoding=UTF-8 to set character encoding to utf8.
Since v5.1.3 Connector/J now auto-detects servers configured with character_set_server=utf8mb4 or treats the Java encoding utf-8 passed using characterEncoding=… as utf8mb4.
See the MySQL Connector J Using Character Sets and Unicode topic for more information.