Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Connecting to mysql 8 fails in pipeline

gabor szabo December 9, 2018

I have a private pipeline where this pipeline using mysql 5.7 works properly, but once I change it to use mysql 8 it fails with

ERROR 2003 (HY000): Can't connect to MySQL server on '127.0.0.1' (111)

 

The config file that works:

 



image: mysql:5.7

definitions:
  services:
    mysql:
      image: mysql:5.7
      environment:
        MYSQL_DATABASE: 'test_db'
        MYSQL_RANDOM_ROOT_PASSWORD: 'yes'
        MYSQL_USER: 'test_user'
        MYSQL_PASSWORD: 'test_password'

pipelines:
  default:
    - step:
        script:
          - mysql --version
          - mysql -h 127.0.0.1 -u test_user --password=test_password -D test_db --execute="SHOW DATABASES"
          - mysql -h 127.0.0.1 -u test_user --password=test_password -D test_db --execute="SHOW VARIABLES"
        services:
          - mysql

 

The config file that fails with the above error message:



image: mysql:8

definitions:
  services:
    mysql:
      image: mysql:8
      environment:
        MYSQL_DATABASE: 'test_db'
        MYSQL_RANDOM_ROOT_PASSWORD: 'yes'
        MYSQL_USER: 'test_user'
        MYSQL_PASSWORD: 'test_password'

pipelines:
  default:
    - step:
        script:
          - mysql --version
          - mysql -h 127.0.0.1 -u test_user --password=test_password -D test_db --execute="SHOW DATABASES"
          - mysql -h 127.0.0.1 -u test_user --password=test_password -D test_db --execute="SHOW VARIABLES"
        services:
          - mysql

 

The only difference is the version number of mysql (in two places)

 

ps. I've created this only as a minimal example of what I see. I am actually trying to use the mysql service from an image that contains my code. I get the same error there and I think if this is solved then my own code will be able to connect  to  the mysql server as well.

 

ps2. I know mysql 8 changed the authentication protocol. I started down this rabbit hole when I started to get this error: "failed: Authentication plugin 'caching_sha2_password' cannot be loaded: /usr/lib/x86_64-linux-gnu/mariadb18/plugin/caching_sha2_password.so: cannot open shared object file:", but I expect(ed) that if both the client and the server are mysql 8 then it would work.

 

 

1 answer

0 votes
gabor szabo December 9, 2018

Huh it seems setting "MYSQL_DEFAULT_AUTH" to "mysql_native_password" in the "Settings" "Repository Variables" makes the pipeline work sometimes.

If I also add a - sleep 5 in the pipeline before I try to access the mysql server then it work most of the time (still not always though).

(So far it worked 7 times and failed once with the env var and the sleep 5)

 

This somehow does not satisfy me.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events