Connect Liquibase and MSSQL Server with Windows Integrated Security

Last updated: July 14, 2025

You can use Liquibase to manage changes to your Microsoft SQL Server database. If your application runs on a Windows-based intranet, you can also use Windows Integrated Security to access your database.

To do this, you must first complete the integrated security setup complete on your server. For more information, see How to: Access SQL Server Using Windows Integrated Security. Then you can set up Liquibase to manage your changes.

To set up Liquibase with MSSQL without using Windows Integrated Security, see Connect Liquibase with Microsoft SQL Server.

Before you begin

Procedure

1

Install drivers

The latest version of Liquibase has a pre-installed driver for this database in the $LIQUIBASE_HOME/internal/lib directory, so you don't need to install it yourself.

If you prefer, you can use environment variables to point to the directory where Liquibase is installed on your machine. You can set environment variables using your operating system's shell. The location of $LIQUIBASE_HOME will depend on where Liquibase was installed on your machine.

Note for Maven users: If you're running Liquibase using the Maven plugin using mvn liquibase:update installing the extension with Maven ensures the right files are available and everything works together automatically. You can manage these extensions by adding them as dependencies in your project’s pom.xml file. When configured this way, Maven automatically downloads the specified JAR files from Maven Central during the build process.

Non-default driver

If you need to install a non-default driver for MSSQL, follow these steps:

  1. Ensure the JDBC driver is version 9.4+ to avoid getting the following error: "This driver is not configured for integrated authentication."

  2. Place your non-default driver in the liquibase/lib directory.

  3. Edit the PATH environment variable: add the filepath of the driver file mssql-jdbc_auth-<version>.x64.dll.

2

Configure your connection

Ensure your MSSQL database is configured:

  1. Ensure your SQL Server ports are open to communicate with the server.

  2. Ensure with your IT admin that an inbound firewall rule for SQL Server ports 1433 TCP/IP and 1434 UDP/IP is enabled.

  3. Restart the Server to take the new changes.

Specify the database URL in the Liquibase properties file:

url: jdbc:sqlserver://hostname;portNumber=1433;databaseName=databaseName;integratedSecurity=true;

Replace hostname with your actual hostname and databaseName with your actual database name. You don't have to set username and password because the authentication is established on the operating system thread to access the SQL Server database.

Tip: To apply a Liquibase Pro key to your project, add the following property to the Liquibase properties file: licenseKey: <paste code here>

3

Test your connection

1. Create a text file called changelog (.sql, .yaml, .json, or .xml) in your project directory and add a changeset.

If you already created a changelog using the init project command, you can use that instead of creating a new file. When adding onto an existing changelog, be sure to only add the changeset and to not duplicate the changelog header.

--liquibase formatted sql --changeset TsviZ:createTable_salesTableZ-1221 CREATE TABLE salesTableZ ( ID int NOT NULL, NAME varchar(20) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, REGION varchar(20) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, MARKET varchar(20) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ) --rollback DROP TABLE salesTableZ

2. Navigate to your project folder in the CLI and run the Liquibase status command to see whether the connection is successful:

liquibase status --username=test --password=test --changelog-file=<changelog.xml>

Note: You can specify arguments in the CLI or keep them in the Liquibase properties file.

If your connection is successful, you'll see a message like this:

4 changesets have not been applied to <your_connection_url> Liquibase command 'status' was executed successfully.

3. Inspect the deployment SQL with the update-sql command

liquibase update-sql --changelog-file=<changelog.xml>

If the SQL that Liquibase generates isn't what you expect, you should review your changelog file and make any necessary adjustments.

4. Then execute these changes to your database with the update command:

liquibase update --changelog-file=<changelog.xml>

If your update is successful, Liquibase runs each changeset and displays a summary message ending with:

Liquibase: Update has been successful. Liquibase command 'update' was executed successfully.

5. From a database UI tool, ensure that your database contains the test_table object you added along with the DATABASECHANGELOG table and DATABASECHANGELOGLOCK table.

Connect Liquibase and MSSQL Server with Windows Integrated Security - Liquibase