Liquibase Windows MySQL - Cannot find database driver: com.mysql.cj.jdbc.Driver

Viewed 5087

I am running the following command in Powershell with a view to get it on CircleCI but am seeing the error: Cannot find database driver: com.mysql.cj.jdbc.Driver

./liquibase.bat --driver=com.mysql.cj.jdbc.Driver --classpath=E:\Software\liquibase-3.10.2\lib\mysql-connector-java-5.1.48.jar --url="jdbc:mysql://REDACTED:3306/sandbox" --changeLogFile=/db.changelog-1.0.mysql.sql --username=REDACTED --password=REDACTED ` generateChangeLog

I have checked the classpath of the mysql-connector file being correct / ran a file exists and is True

[System.IO.File]::Exists('E:\Software\liquibase-3.10.2\lib\mysql-connector-java-5.1.48.jar')

The PATH variable has the Liquibase root folder after checking the output of

$env:PATH

Any pointers would be greatly appreciated

Thanks

2 Answers

Change your driver to

--driver=com.mysql.jdbc.Driver

or update your mysql dependency. I believe your dependency has package com.mysql.jdbc but mysql updated their library with new package.

Try to use this one for example.

For me, it worked when I added mysql dependency for the plugin:

        <plugin>
            <groupId>org.liquibase</groupId>
            <artifactId>liquibase-maven-plugin</artifactId>
            <version>4.15.0</version>
            <configuration>
                <propertyFile>${liquibase.properties}</propertyFile>
            </configuration>
            <dependencies>
                <dependency>
                    <groupId>mysql</groupId>
                    <artifactId>mysql-connector-java</artifactId>
                    <version>8.0.26</version>
                </dependency>
            </dependencies>
        </plugin>
Related