gpt4 book ai didi

Liquibase connection could not be created to Database(无法创建到数据库的LiquiBase连接)

转载 作者:bug小助手 更新时间:2023-10-24 22:45:52 26 4
gpt4 key购买 nike



Liquibase is unable to connect to the database, when I am running liquibase against my database, I get the following error:

Liquibase无法连接到数据库,当我对我的数据库运行Liquibase时,我收到以下错误:


liquibase_1  | Starting Liquibase at 21:40:22 (version 4.23.1 #12042 built at 2023-08-10 13:48+0000)
liquibase_1 | Liquibase Version: 4.23.1
liquibase_1 | Liquibase Open Source 4.23.1 by Liquibase
liquibase_1 |
liquibase_1 | Unexpected error running Liquibase: Connection could not be created to jdbc:mysql://mysql_db:3307/patshala with driver com.mysql.cj.jdbc.Driver. Communications link failure
liquibase_1 |
liquibase_1 | The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
liquibase_1 | - Caused by: Connection refused

Below is my docker compose file, is there anything I am missing here?

下面是我的码头撰写文件,我有什么遗漏的吗?


version: '3.8'

services:
mysql_db:
image: mysql:5.7
environment:
MYSQL_ROOT_PASSWORD: password
MYSQL_DATABASE: patshala
MYSQL_USER: mysql
MYSQL_PASSWORD: password
volumes:
- ./db:/docker-entrypoint-initdb.d/
ports:
- "3307:3306"
networks:
- app-network

liquibase:
image: liquibase/liquibase:latest
command: ["--url=jdbc:mysql://mysql_db:3307/patshala", "--username=mysql", "--password=password", "--changeLogFile=/db/changelog/db.changelog.xml", "update"]
volumes:
- ./db:/liquibase/changelog
- ./mysql-connector-j-8.1.0.jar:/liquibase/lib/mysql-connector-j-8.1.0.jar
depends_on:
- mysql_db
networks:
- app-network


networks:
app-network:
driver: bridge

更多回答
优秀答案推荐

You are exposing port 3307 to the host machine. Both liquibase and mysql are in the same network app-network so if you use port 3307, liquibase could not connect to it. So:

您将端口3307暴露给主机。Liqubase和MySQL都在同一个网络应用程序网络中,所以如果你使用端口3307,Liqubase无法连接到它。所以:



  • Try to change to port 3306

  • If still persists, make sure mysql is up and running (checking log and maybe connecting from your host machine)



volumes:
- ./db:/liquibase/changelog
- ./mysql-connector-j-8.1.0.jar:/liquibase/lib/mysql-connector-j-8.1.0.jar

Based from the latest documentation of Liquibase, you need to create a Dockerfile in order to install the MySQL driver to Liquibase.

根据Liquibase的最新文档,您需要创建Docker文件才能将MySQL驱动程序安装到Liquibase。


Reference: MySQL Licensing Restriction

参考:MySQL许可限制


更多回答

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com