![](/img/trans.png)
[英]Error: Client does not support authentication protocol requested by server; consider upgrading MySQL client
[英]Docker Flyway MySQL 8 : Client does not support authentication protocol requested by server. Consider upgrading MariaDB client
我在docker容器中運行我的應用程序,其中flyway遷移工具在連接到MySQL DB(8.0.11)時出錯:這是完整的錯誤:
Unable to obtain connection from database (jdbc:mysql://docker-mysql:3306) for user 'deepti': Client does not support authentication protocol requested by server. Consider upgrading MariaDB client. plugin was = caching_sha2_password
這是我的docker-compose.yml:
version: '3' services: docker-mysql: image: mysql:8.0.11 environment: - MYSQL_ROOT_PASSWORD=... - MYSQL_DATABASE=test1 - MYSQL_USER=... - MYSQL_PASSWORD=... flyway-service-i: image: boxfuse/flyway command: -url=jdbc:mysql://docker-mysql:3306 -schemas=test1 -user=... -password=... migrate volumes: - "../resources/db/migration:/flyway/sql" depends_on: - docker-mysql spring-boot-jpa-docker-webapp: image: deepti/spring-boot-docker depends_on: - docker-mysql ports: - 8080:8080 environment: - DATABASE_HOST=docker-mysql - DATABASE_USER=... - DATABASE_PASSWORD=... - DATABASE_NAME=test1 - DATABASE_PORT=3306
任何人都可以幫我這個。 謝謝
MySQL中的默認身份驗證方法在8.0.4版中更改為caching_sha2_password
。 它看起來不像MariaDB連接器支持它 。
您可以通過添加如下所示的command
將默認身份驗證插件還原為舊版本:
version: '3'
services:
docker-mysql:
image: mysql:8.0.11
command: --default-authentication-plugin=mysql_native_password
environment:
...
對於已使用caching_sha2_password
身份驗證方法創建的db中的任何現有用戶,您可以更改用戶以使用mysql_native_password
:
ALTER USER 'username'@'ip_address' IDENTIFIED WITH mysql_native_password BY 'password';
或者只使用docker-compose rm
刪除現有容器。
我在這個存儲庫中創建了一個工作示例。 這是成功的輸出:
Flyway Community Edition 5.1.4 by Boxfuse
Database: jdbc:mysql://docker-mysql:3306/test1 (MySQL 8.0)
WARNING: You are connected to a MySQL database using the MariaDB driver. This is known to cause issues. An upgrade to Oracle's MySQL JDBC driver is highly recommended.
Successfully validated 1 migration (execution time 00:00.010s)
Creating Schema History table: `test1`.`flyway_schema_history`
Current version of schema `test1`: << Empty Schema >>
Migrating schema `test1` to version 1.0 - init
Successfully applied 1 migration to schema `test1` (execution time 00:00.290s)
正如您所看到的,雖然它可以正常工作,但是對於使用MySQL的MariaDB驅動程序的問題存在警告。
另一種選擇是下載官方MySQL JDBC驅動程序 ,將其添加到./drivers
目錄並將其掛載到./drivers
容器中:
flyway-service-i:
image: boxfuse/flyway
command: ...
volumes:
- "./sql:/flyway/sql"
- "./drivers:/flyway/drivers"
這也有效:
Flyway Community Edition 5.1.4 by Boxfuse
Database: jdbc:mysql://docker-mysql:3306/test1 (MySQL 8.0)
Successfully validated 1 migration (execution time 00:00.011s)
Creating Schema History table: `test1`.`flyway_schema_history`
Current version of schema `test1`: << Empty Schema >>
Migrating schema `test1` to version 1.0 - init
Successfully applied 1 migration to schema `test1` (execution time 00:00.229s)
但要擺脫以下警告:
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.
我確實需要在jdbc url中添加verifyServerCertificate=false
和useSSL=true
:
jdbc:mysql://docker-mysql:3306/test1?verifyServerCertificate=false&useSSL=true
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.