无法在Laravel Gitlab CI中迁移数据库

时间:2019-11-09 17:56:52

标签: php laravel continuous-integration gitlab-ci devops

我使用gitlab ci为laravel配置了

一切都会好起来的,但是当它到达“迁移命令”时,它会失败。

这是我的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

这是我收到的错误:

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')

1 个答案:

答案 0 :(得分:0)

我强烈建议将mysql:latest图像替换为mysql:5.7,因为MySQL 8使用by default another authentication method

您的Yaml文件应如下所示:

image: php:latest

services:
  - mysql:5.7
# rest of your file