I am currently evaluating Liquibase as a Database Version Control solution. I am running on Ubuntu 16.04 LTS with java version "1.8.0_181". I have installed Liquibase 3.6.2, I have setup two MySQL 5.7 docker containers on ports 4408 and 4409 for testing, and I have downloaded MySQL Connector/J 8.0 which is recommended for use with MySQL Server 5.7. I placed mysql-connector-java-8.0.12.jar
in /usr/local/liquibase/lib/ per the liquibase readme:
The "lib" directory is automatically scanned by the liquibase scripts and all .jar files are added to the classpath. If you have JDBC drivers or Liquibase extensions that you want to be automatically included, add them to this directory.
In my project test directory I have the following liquibase.properties
file:
classpath=/usr/local/liquibase/lib/mysql-connector-java-8.0.12.jar
driver=com.mysql.cj.jdbc.Driver
changeLogFile=db.changelog-1.0.xml
url="jdbc:mysql://localhost:4409/myDatabase"
username=myUser
password=myPassword
I want to generate a changelog from the current state of my development database on port 4409 and then (after integrating routines and triggers) run that changelog on an empty database on port 4408, then do a diff to see if the two are identical and then from there perform a diff with the production database to test how well the changes are integrated. So my first step is to run the following command from the same directory that my liquibase.porperties
file is:
liquibase generateChangeLog
The result is the following output:
Starting Liquibase at Thu, 23 Aug 2018 07:37:21 PDT (version 3.6.2 built at 2018-07-03 11:28:09)
Unexpected error running Liquibase: liquibase.exception.DatabaseException: Connection could not be created to "jdbc:mysql://localhost:4409/myDatabase" with driver com.mysql.cj.jdbc.Driver. Possibly the wrong driver for the given database URL
liquibase.exception.DatabaseException: liquibase.exception.DatabaseException: liquibase.exception.DatabaseException: Connection could not be created to "jdbc:mysql://localhost:4409/myDatabase" with driver com.mysql.cj.jdbc.Driver. Possibly the wrong driver for the given database URL
at liquibase.integration.commandline.CommandLineUtils.createDatabaseObject(CommandLineUtils.java:132)
at liquibase.integration.commandline.Main.doMigration(Main.java:953)
at liquibase.integration.commandline.Main.run(Main.java:191)
at liquibase.integration.commandline.Main.main(Main.java:129)
Caused by: liquibase.exception.DatabaseException: liquibase.exception.DatabaseException: Connection could not be created to "jdbc:mysql://localhost:4409/myDatabase" with driver com.mysql.cj.jdbc.Driver. Possibly the wrong driver for the given database URL
at liquibase.database.DatabaseFactory.openConnection(DatabaseFactory.java:254)
at liquibase.database.DatabaseFactory.openDatabase(DatabaseFactory.java:149)
at liquibase.integration.commandline.CommandLineUtils.createDatabaseObject(CommandLineUtils.java:97)
... 3 common frames omitted
Caused by: liquibase.exception.DatabaseException: Connection could not be created to "jdbc:mysql://localhost:4409/myDatabase" with driver com.mysql.cj.jdbc.Driver. Possibly the wrong driver for the given database URL
at liquibase.database.DatabaseFactory.openConnection(DatabaseFactory.java:249)
... 5 common frames omitted
Note: Since I have included the connector file in the liquibase lib directory, per the quote from the readme above, I shouldn't have to specify the classpath. I have tried it both ways and received the same error. Further, I have tried with mysql-connector-java-5.1.32.jar
which is what is in my maven local repo, and adjusted the driver in liquibase properties file to driver=com.mysql.jdbc.Driver
, and still the same error.
Now, here is where it gets confusing: If instead of using the liquibase properties file if I execute the following command:
liquibase \
--classpath=/usr/local/liquibase/lib/mysql-connector-java-8.0.12.jar \
--driver=com.mysql.cj.jdbc.Driver \
--changeLogFile=db.changelog-1.0.xml \
--url="jdbc:mysql://localhost:4409/myDatabase" \
--username=myUser \
--password=myPassword \
generateChangeLog
It successfully generates the changelog file with the following output:
Starting Liquibase at Thu, 23 Aug 2018 09:54:41 PDT (version 3.6.2 built at 2018-07-03 11:28:09)
Thu Aug 23 09:54:43 PDT 2018 WARN: Establishing SSL connection without
server's identity verification is not recommended. According to MySQL
5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be
established by default if explicit option isn't set. For compliance
with existing applications not using SSL the verifyServerCertificate
property is set to 'false'. You need either to explicitly disable SSL
by setting useSSL=false, or set useSSL=true and provide truststore for
server certificate verification.
Liquibase command 'generateChangeLog' was executed successfully.
Now, I have other issues that I would like to resolve like why the changelog that is generated includes remarks but when applying the changelog to an empty database the remarks on the first column of every table is not included or when I do a diffChangeLog between the two and try to update the database with the resulting changelog I get and error that changes have validation failures: setColumnRemarks is not supported on mysql, or the the views that the diff generated have replaceIfExists enabled yet the update throws an error that the table already exists. Anyhow, before I post a separate thread for these issues, I thought why not work from the first issue I could not resolve to see if somewhere along the way this may be causing other issues.
--logLevel=debug
on commandline :) – Jens