init start-h2

The init start-h2 command starts the in-memory H2 database included in the Liquibase installation package to get started and test how Liquibase works. It is available in Liquibase 4.7.0 and later.

If you run the liquibase init project command, you can use H2 only with one of the following options:

  • Creating the Liquibase project with the default values [Y].
  • Customizing the values [C] but keeping the default URL, username, and password.

The H2 database console opens automatically in a browser on port 9090 and requires a new command line or terminal window.

Syntax

To start the H2 database, open a new terminal window and run the following command:

liquibase init start-h2

To continue running commands, use another terminal window.

Detached mode in flow files

In Liquibase 4.29.0 and later, you can run the init start-h2 command in a detached mode. Detached mode is useful if you want to run the init start-h2 command within a flow file via the flow command. This allows Liquibase to continue processing actions in the file. For example:

stages:
  Default:
    actions:
      - type: liquibase
        command: init start-h2
        cmdArgs: {detached: true}
      - type: liquibase
        command: update
        cmdArgs: {changelog-file: example-changelog.sql}

Then you can successfully run the flow command to run these actions:

liquibase flow

Command parameters

Attribute Definition Requirements

--bind-address=<string>

Network address to bind to. Default: 127.0.0.1

Optional

--db-port=<string>

Port to run h2 database on. Default: 9090

Optional

--detached=<true|false>

Liquibase 4.29.0+. When set to true, Liquibase initiates the H2 database in a new thread without blocking, allowing use within the flow command. When false, Liquibase initiates H2 normally. Regardless of the parameter setting, data stored in the H2 database is cleared when the JVM exits, such as at the end of the flow command. Default: false

Optional

--launch-browser=<true|false>

Whether to open a browser to the database's web interface. Default: true

Optional

--password=<string>

Password to use for created h2 user. Default: letmein

Optional

--username=<string>

Username to create in h2. Default: dbuser

Optional

--web-port=<string>

Port to run h2's web interface on. Default: 8080

Optional
Attribute Definition Requirements

cmdArgs: { bind-address: "<string>" }

Network address to bind to. Default: 127.0.0.1

Optional

cmdArgs: { db-port: "<string>" }

Port to run h2 database on. Default: 9090

Optional

cmdArgs: { detached: "<true|false>" }

Liquibase 4.29.0+. When set to true, Liquibase initiates the H2 database in a new thread without blocking, allowing use within the flow command. When false, Liquibase initiates H2 normally. Regardless of the parameter setting, data stored in the H2 database is cleared when the JVM exits, such as at the end of the flow command. Default: false

Optional

cmdArgs: { launch-browser: "<true|false>" }

Whether to open a browser to the database's web interface. Default: true

Optional

cmdArgs: { password: "<string>" }

Password to use for created h2 user. Default: letmein

Optional

cmdArgs: { username: "<string>" }

Username to create in h2. Default: dbuser

Optional

cmdArgs: { web-port: "<string>" }

Port to run h2's web interface on. Default: 8080

Optional
Attribute Definition Requirements

liquibase.command.bindAddress: <string>

liquibase.command.init.startH2.bindAddress: <string>

Network address to bind to. Default: 127.0.0.1

Optional

liquibase.command.dbPort: <string>

liquibase.command.init.startH2.dbPort: <string>

Port to run h2 database on. Default: 9090

Optional

liquibase.command.detached: <true|false>

liquibase.command.init.startH2.detached: <true|false>

Liquibase 4.29.0+. When set to true, Liquibase initiates the H2 database in a new thread without blocking, allowing use within the flow command. When false, Liquibase initiates H2 normally. Regardless of the parameter setting, data stored in the H2 database is cleared when the JVM exits, such as at the end of the flow command. Default: false

Optional

liquibase.command.launchBrowser: <true|false>

liquibase.command.init.startH2.launchBrowser: <true|false>

Whether to open a browser to the database's web interface. Default: true

Optional

liquibase.command.password: <string>

liquibase.command.init.startH2.password: <string>

Password to use for created h2 user. Default: letmein

Optional

liquibase.command.username: <string>

liquibase.command.init.startH2.username: <string>

Username to create in h2. Default: dbuser

Optional

liquibase.command.webPort: <string>

liquibase.command.init.startH2.webPort: <string>

Port to run h2's web interface on. Default: 8080

Optional
Attribute Definition Requirements

JAVA_OPTS=-Dliquibase.command.bindAddress=<string>

JAVA_OPTS=-Dliquibase.command.init.startH2.bindAddress=<string>

Network address to bind to. Default: 127.0.0.1

Optional

JAVA_OPTS=-Dliquibase.command.dbPort=<string>

JAVA_OPTS=-Dliquibase.command.init.startH2.dbPort=<string>

Port to run h2 database on. Default: 9090

Optional

JAVA_OPTS=-Dliquibase.command.detached=<true|false>

JAVA_OPTS=-Dliquibase.command.init.startH2.detached=<true|false>

Liquibase 4.29.0+. When set to true, Liquibase initiates the H2 database in a new thread without blocking, allowing use within the flow command. When false, Liquibase initiates H2 normally. Regardless of the parameter setting, data stored in the H2 database is cleared when the JVM exits, such as at the end of the flow command. Default: false

Optional

JAVA_OPTS=-Dliquibase.command.launchBrowser=<true|false>

JAVA_OPTS=-Dliquibase.command.init.startH2.launchBrowser=<true|false>

Whether to open a browser to the database's web interface. Default: true

Optional

JAVA_OPTS=-Dliquibase.command.password=<string>

JAVA_OPTS=-Dliquibase.command.init.startH2.password=<string>

Password to use for created h2 user. Default: letmein

Optional

JAVA_OPTS=-Dliquibase.command.username=<string>

JAVA_OPTS=-Dliquibase.command.init.startH2.username=<string>

Username to create in h2. Default: dbuser

Optional

JAVA_OPTS=-Dliquibase.command.webPort=<string>

JAVA_OPTS=-Dliquibase.command.init.startH2.webPort=<string>

Port to run h2's web interface on. Default: 8080

Optional
Attribute Definition Requirements

LIQUIBASE_COMMAND_BIND_ADDRESS=<string>

LIQUIBASE_COMMAND_INIT_START_H2_BIND_ADDRESS=<string>

Network address to bind to. Default: 127.0.0.1

Optional

LIQUIBASE_COMMAND_DB_PORT=<string>

LIQUIBASE_COMMAND_INIT_START_H2_DB_PORT=<string>

Port to run h2 database on. Default: 9090

Optional

LIQUIBASE_COMMAND_DETACHED=<true|false>

LIQUIBASE_COMMAND_INIT_START_H2_DETACHED=<true|false>

Liquibase 4.29.0+. When set to true, Liquibase initiates the H2 database in a new thread without blocking, allowing use within the flow command. When false, Liquibase initiates H2 normally. Regardless of the parameter setting, data stored in the H2 database is cleared when the JVM exits, such as at the end of the flow command. Default: false

Optional

LIQUIBASE_COMMAND_LAUNCH_BROWSER=<true|false>

LIQUIBASE_COMMAND_INIT_START_H2_LAUNCH_BROWSER=<true|false>

Whether to open a browser to the database's web interface. Default: true

Optional

LIQUIBASE_COMMAND_PASSWORD=<string>

LIQUIBASE_COMMAND_INIT_START_H2_PASSWORD=<string>

Password to use for created h2 user. Default: letmein

Optional

LIQUIBASE_COMMAND_USERNAME=<string>

LIQUIBASE_COMMAND_INIT_START_H2_USERNAME=<string>

Username to create in h2. Default: dbuser

Optional

LIQUIBASE_COMMAND_WEB_PORT=<string>

LIQUIBASE_COMMAND_INIT_START_H2_WEB_PORT=<string>

Port to run h2's web interface on. Default: 8080

Optional

Related links

For more information about using Liquibase and H2, see the following pages: