首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >如何用天桥连接到已停靠的mysql数据库

如何用天桥连接到已停靠的mysql数据库
EN

Stack Overflow用户
提问于 2022-05-25 23:15:20
回答 1查看 531关注 0票数 0

我是一个新的飞道,并希望使用它与mysql数据库在码头(通过对接-合成)。我收到一个与加密相关的错误。让我感到困惑的是,我可以通过MySql工作台使用完全相同的凭据连接到它。我的文件夹结构与这里的文档中的一个相同:https://flywaydb.org/documentation/usage/commandline/

我无法尝试获得它需要配置的任何关键东西,文档对它也没有任何帮助。

flyway-8.5.11

  • OS:

  • 天桥版本: windows 10
  • Credentials:查看flyway.conf

我包括5个文件/代码片段,以便:

  • docker-compose.yml
  • mysql.Dockerfile
  • my.cnf
  • flyway.conf
  • The天桥命令我正在执行(和错误)

任何建议都是有用的。

docker-compose.yml文件

代码语言:javascript
运行
复制
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" 

mysql容器的Dockerfile (mysql.Dockerfile)

代码语言:javascript
运行
复制
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

用于初始化mysql数据库的my.cnf文件

代码语言:javascript
运行
复制
[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

我修改的flyway.conf的一部分(其他一切保持不变)

代码语言:javascript
运行
复制
# 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_#"

命令我正在执行,并出错:

代码语言:javascript
运行
复制
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)
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2022-05-26 13:55:30

在docker-come.yml中,而不是这个:

代码语言:javascript
运行
复制
command: --default-authentication-plugin=mysql_native_password

尝试以下语法:

代码语言:javascript
运行
复制
command: ["--default-authentication-plugin=mysql_native_password"]
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/72385060

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档