Can’t connect to MySQL server in Git-Hub Action

I installed MySQL 9.0 in the docker environment using mirromutth/[email protected] [1] in GitHub Action. I set it up in Spring project as follows.

File application.yml

spring:
  datasource:
    url: jdbc:mysql://localhost:3306/testdb?serverTimezone=UTC
    username: root
    password: 1234
  jpa:
    database-platform: org.hibernate.dialect.MySQLDialect
    open-in-view: false
    show-sql: true
    properties:
      hibernate:
        format_sql: true
#        hbm2ddl.auto: create

When I uncomment the annotation part from this code, it didn’t connect to mysql in github action. Why does that one line change the result?

[workflow]

name: CI

on:
  push:
    branches: [ "main" ]
  pull_request:
    branches: [ "main" ]

jobs:
  build:
    permissions:
      contents: read
    uses: ./.github/workflows/build.yml

  test:
    permissions:
      contents: read
    uses: ./.github/workflows/test.yml

  dependency-submission:
    permissions:
      contents: write
    uses: ./.github/workflows/dependency-submission.yml
name: test

on:
  workflow_call:

jobs:
  test:
    runs-on: ubuntu-latest
    permissions:
      contents: read

    steps:
      - uses: actions/checkout@v4
      
      - name: Set up MySQL
        uses: mirromutth/[email protected]
        with:
          host port: 3306
          container port: 3306
          character set server: 'utf8mb4'
          collation server: 'utf8mb4_general_ci'
          mysql version: '9.0'
          mysql database: 'testdb'
          mysql user: 'root'
          mysql password: '1234'

      - name: Get MySQL container ID
        run: echo "::set-output name=container_id::$(docker ps -q -f ancestor=mysql:9.0)"
        id: container_id

      - name: Print MySQL version
        run: |
          docker exec -i ${{ steps.container_id.outputs.container_id }} 
          mysql -uroot -p1234 -e "SELECT VERSION();"

      - uses: actions/checkout@v4

      - name: Set up JDK 17
        uses: actions/setup-java@v4
        with:
          java-version: '17'
          distribution: 'temurin'

      - name: Setup Gradle
        uses: gradle/actions/setup-gradle@v3

      - name: test with Gradle Wrapper
        run: ./gradlew test -s

When I tried to connect with Unix socket, I got the error message like
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) Error: Process completed with exit code 1.

When I set IP as a 127.0.0.1 and tried to connect with TCP/IP, I got the error message like ERROR 2003 (HY000): Can't connect to MySQL server on '127.0.0.1:3306' (111)

When I set IP as a localhost and tried to connect with TCP/IP, I got the error message like ERROR 2003 (HY000): Can't connect to MySQL server on 'localhost:3306' (111)

And I waited for a long time using mysqladmin ping but it was not connected.

MySQL container was running, and ip:port had no problem. The database name also matches. I tried all the other methods (TCP connection, permission setting, socket path check, etc.) but it didn’t work. Just that comment alone will change the outcome of the run. I’ve seen the following but I haven’t got a solution.

How to connect to MySQL databas using GitHub Actions?

Installing MySQL in Docker fails with error message “Can’t connect to local MySQL server through socket”

Any help or offer would be appreciated.

[1] https://github.com/mirromutth/mysql-action

2

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật