0

I have a configuration for laravel with gitlab ci

Everything is going to be ok but when it reaches 'Migrating Command', it fails.

This is my yaml:

image: php:latest

services:
  - mysql:latest

variables:
  MYSQL_ROOT_PASSWORD: root
  MYSQL_USER: homestead
  MYSQL_PASSWORD: secret
  MYSQL_DATABASE: homestead
  DB_HOST: mysql

stages:
  - test

cache:
  paths:
    - vendor/

test:
  stage: test
  before_script:
    - apt-get update -yqq
    - apt-get install gnupg -yqq
    - apt-get install git libcurl4-gnutls-dev libicu-dev libmcrypt-dev libvpx-dev libjpeg-dev libpng-dev libxpm-dev zlib1g-dev libfreetype6-dev libxml2-dev libexpat1-dev libbz2-dev libgmp3-dev libldap2-dev unixodbc-dev libpq-dev libsqlite3-dev libaspell-dev libsnmp-dev libpcre3-dev libtidy-dev -yqq libzip-dev
    - docker-php-ext-install mbstring pdo_mysql curl json intl gd xml zip bz2 opcache
    - pecl install xdebug
    - docker-php-ext-enable xdebug
    - curl -sS https://getcomposer.org/installer | php
    - php composer.phar install
    - cp .env.example .env
    - php artisan key:generate
    - php artisan config:cache
    - php artisan migrate -v
  script:
    - php vendor/bin/phpunit --coverage-text --colors=never
  only:
    - master

This is the error I received:

Illuminate\Database\QueryException  : SQLSTATE[HY000] [2054] The server requested authentication method unknown to the client (SQL: select * from information_schema.tables where table_schema = laravel and table_name = migrations and table_type = 'BASE TABLE')
Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
Tomas Shelby
  • 203
  • 4
  • 13
  • 1
    Possible duplicate of [php mysqli\_connect: authentication method unknown to the client \[caching\_sha2\_password\]](https://stackoverflow.com/questions/50026939/php-mysqli-connect-authentication-method-unknown-to-the-client-caching-sha2-pa) – Salim Djerbouh Nov 09 '19 at 18:02

1 Answers1

0

I highly suggest replacing the mysql:latest image by mysql:5.7 since the MySQL 8 use by default another authentication method.

Your yaml file should look like something like this:

image: php:latest

services:
  - mysql:5.7
# rest of your file
Mathieu Bour
  • 666
  • 4
  • 23
  • 1
    If you do use mysql 8, and can add arguments to the container started that runs mysql, the flags to add are `--default-authentication-plugin=mysql_native_password`, which will have mysql 8 run with the same authentication as mysql 5.7 – fideloper Apr 02 '22 at 21:30