Reputation: 75
I am new to flyway, and want to use it against a mysql database in docker (through docker-compose). I receive an error related to the encryption. What baffles me, is that I can connect fine to it using the exact same credentials via MySql workbench. My folder structure is identical to the one pictured in their documentation here: https://flywaydb.org/documentation/usage/commandline/
I'm lost on trying to get whatever key things it needs configured, documentation hasn't been helpful for it either.
I include 5 files/code snippets, in order:
Any advice is helpful.
docker-compose.yml file
version: '3.9'
services:
mysql:
build:
context: ./docker-compose/
dockerfile: mysql.Dockerfile
container_name: "mysql"
restart: always
command: --default-authentication-plugin=mysql_native_password
environment:
# MYSQL_DB_HOST: "mysql"
# MYSQL_DATABASE: "test_db"
# MYSQL_USER: "test_user"
# MYSQL_PASSWORD: "test_password_#"
MYSQL_ROOT_PASSWORD: "test_root_pass_#"
MYSQL_PORT: "3306"
ports:
- "3306:3306"
expose:
- "3306"
volumes:
# This is the my.cnf file that configures the database
- "./docker-compose/mysql/store:/var/lib/mysql"
Dockerfile for the mysql container (mysql.Dockerfile)
FROM mysql:8.0.29
COPY mysql/cnf/my.cnf /etc/my.cnf
RUN chmod 0444 /etc/my.cnf
COPY mysql/charsets/Index.xml /usr/share/mysql-8.0/charsets/Index.xml
COPY mysql/charsets/latin1.xml /usr/share/mysql-8.0/charsets/latin1.xml
RUN chmod 0444 /usr/share/mysql-8.0/charsets/Index.xml
RUN chmod 0444 /usr/share/mysql-8.0/charsets/latin1.xml
my.cnf file for initializing mysql database
[MYSQLD]
default-storage-engine=InnoDB
collation-server = utf8mb4_0900_ai_ci
init-connect='SET NAMES utf8mb4'
character-set-server = utf8mb4
tls_version=TLSv1.2,TLSv1.3
#Settings for Containers to work
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
pid-file=/var/run/mysqld/mysqld.pid
user=mysql
# activate roles on login by default, so roles can be used easily
activate_all_roles_on_login=1
innodb_flush_method=O_DIRECT
#log_warnings is log_error_verbosity as of 5.7 and defaults to 3, the most verbose; log_warnings is no longer needed
#log_warnings=2
###GTIDs enablement, settings section
gtid_mode=ON
enforce-gtid-consistency=ON
key_buffer_size=128M
slow_query_log=1
slow_query_log_file=/var/lib/mysql/localDB-slow.log
long_query_time=3
table_open_cache=18432
table_open_cache_instances=8
#log-queries-not-using-indexes
log-bin=localDB-bin
log_error=localDB.err
relay-log=localDB-relay-bin
server-id=1
sql_mode=STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION
#set min word length to 3 for full text searching of FAQs
ft_min_word_len=2
#password_validation component settings
loose_validate_password.length=15
[mysql]
default-character-set = utf8mb4
[client]
default-character-set = utf8mb4
host=127.0.0.1
Part of the flyway.conf that I modified (everything else stayed the same)
# Redshift* : jdbc:redshift://<host>:<port>/<database>
flyway.url=jdbc:mysql://localhost:3306/fwtest
# Fully qualified classname of the JDBC driver (autodetected by default based on flyway.url)
# flyway.driver=
# User to use to connect to the database. Flyway will prompt you to enter it if not specified, and if the JDBC
# connection is not using a password-less method of authentication.
flyway.user=root
# Password to use to connect to the database. Flyway will prompt you to enter it if not specified, and if the JDBC
# connection is not using a password-less method of authentication.
flyway.password="test_user_pass_#"
Command I'm executing, and error:
flyway migrate -configFiles="conf/flyway.conf"
ERROR: Unable to obtain connection from database (jdbc:mysql://localhost:3306/fwtest) for user 'root': Could not connect to address=(host=localhost)(port=3306)(type=master) : RSA public key is not available client side (option serverRsaPublicKeyFile
not set)
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
SQL State : S1009
Error Code : 0
Message : Could not connect to address=(host=localhost)(port=3306)(type=master) : RSA public key is not available client side (option serverRsaPublicKeyFile not set)
Caused by: java.sql.SQLTransientConnectionException: Could not connect to address=(host=localhost)(port=3306)(type=master) : RSA public key is not available client side (option serverRsaPublicKeyFile not set)
Caused by: java.sql.SQLException: RSA public key is not available client side (option serverRsaPublicKeyFile not set)
Upvotes: 2
Views: 3174
Reputation: 389
In docker-compose.yml, instead of this:
command: --default-authentication-plugin=mysql_native_password
try this syntax:
command: ["--default-authentication-plugin=mysql_native_password"]
Upvotes: 2