4

I've recently encountered problems when testing code in CircleCi 2. Parts of our config.yml:

jobs:
  build:
    environment:
    docker:
      ...
      - image: circleci/mysql
      - image: rabbitmq:3-alpine
    working_directory: ~/webapp

    steps:
      ...
      - run:
          name: Prepare DB
          command: echo "create database" | mysql --host 127.0.0.1

The build fails at Prepare DB with

ERROR 2059 (HY000): Authentication plugin 'caching_sha2_password' cannot be loaded: Error loading shared library /usr/lib/mysql/plugin/caching_sha2_password.so: No such file or directory Exited with code 1

This error only occurred now, and no changes has been made to the circle / mysql setup.

From e.g. https://stackoverflow.com/a/49944625/2713641 it is specified that one can set a --default-authentication-plugin=mysql_native_password flag but not sure if that applies here, or how to apply it in a circle ci setup.

simen-andresen
  • 2,217
  • 4
  • 25
  • 39
  • 1
    Added the mysql 8.0 tag because this question is mysql 8.0 related – Raymond Nijland Apr 23 '18 at 10:59
  • Seems to be the same issue as here: [Authentication plugin 'caching\_sha2\_password' cannot be loaded](https://stackoverflow.com/questions/49194719/authentication-plugin-caching-sha2-password-cannot-be-loaded) – halfer May 03 '20 at 00:10

2 Answers2

9

This problem is mysql 8 specific (as pointed out by Raymond), and the error occured due to CircleCi upgrading their latest docker image to mysql 8. Therefore, the solution to our specific case (we are using mysql 5.7) was simply to specify the appropriate tag for the mysql docker image:

jobs:
  build:
    environment:
    docker:
      ...
      - image: circleci/mysql:5.7
simen-andresen
  • 2,217
  • 4
  • 25
  • 39
  • Some people use mysql 8 for a reason and their setups are not backwards compatible with mysql 5.7. In this case @Yannick's answer is better – nickforall Mar 31 '21 at 12:30
3

If you want to keep mysql 8, configure it this way

- image: circleci/mysql:latest
  # just add this:
  command: [--default-authentication-plugin=mysql_native_password]
  environment:
    MYSQL_DATABASE: myapp_test

Source : https://discuss.circleci.com/t/solved-mysql-8-0-without-mysql2-authentication-plugin-caching-sha2-password-cannot-be-loaded/25791