Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MySQL server has gone away #10

Open
mehdibo opened this issue Mar 24, 2020 · 8 comments
Open

MySQL server has gone away #10

mehdibo opened this issue Mar 24, 2020 · 8 comments

Comments

@mehdibo
Copy link

mehdibo commented Mar 24, 2020

I get this error from time to time:

SQLSTATE[HY000] [2006] MySQL server has gone away

I just re-run the job multiple times until it works.
This is my conf for MySQL setup:

- name: Setup MySQL
        uses: mirromutth/[email protected]
        with:
          mysql database: test
          mysql user: test
          mysql password: test
@drfraker
Copy link

I got the same error when switching from mysql 5.7 to 8.0. Reverting back to 5.7 fixed the issue. @mehdibo did you find a solution to the problem other than reverting back to 5.7?

@mehdibo
Copy link
Author

mehdibo commented May 16, 2020

No, I always had the issue, it would work for sometime and then randomly stops working.

I eventually switched to Travis Ci.

Try building your own docker container, I remember using Github Actions with docker-compose that had a db container and it worked fine.

@almasaeed2010
Copy link

Adding a sleep 15 command to wait for the mysql server to become available fixed this issue for me

- name: Wait for MySQL
  run: sleep 15

@Zen0x7
Copy link

Zen0x7 commented Feb 15, 2021

I agree with @almasaeed2010

When i had to make a pipeline for GitLab CI i use the following code before my test execution because sometimes the MySQL service fails.

# Ensure that mysql server is up and running
ping -c 3 mysql

But sleep 15 will lock the docker instance for sure. Adding static cost for the CI process, a better solution than retry the execution hoping that works as a magic trick.

@NBajanca
Copy link

After a lot of time with inconsistent errors, I did this:

(...)
env:
      MYSQL_ROOT_PASSWORD: password
          
    steps:
      (...) first steps, but the sooner you call MySQL, the better
      
      - name: Setup MySQL
        uses: mirromutth/[email protected]
        with:
          mysql root password: $MYSQL_ROOT_PASSWORD

      (...) all other things that don't need MySQL

      - name: Wait for MySQL
        run: |
          while ! mysqladmin ping --host=127.0.0.1 --password=$MYSQL_ROOT_PASSWORD --silent; do
            sleep 1
          done

      (...) steps where you need MySQL

If you think it is a good approach, I don't have a problem adding this note in the README file (and doing a PR) so new users don't waste time.

@akotek
Copy link

akotek commented Jan 10, 2022

better add some timeout as well @NBajanca

@sourcecodeit
Copy link

That should definitely added to README.txt to avoid waste of time.

@rodber
Copy link

rodber commented Jul 19, 2023

You may need to add this option:

-P 3800 

If you are using:

host port: 3800

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants