【问题标题】:I am getting "could not find driver " exception while build my laravel application in gitlab CI在 gitlab CI 中构建我的 laravel 应用程序时出现“找不到驱动程序”异常
【发布时间】:2019-07-26 12:15:45
【问题描述】:

在使用 gitlab CI/CD 构建我的 laravel 应用程序时,我遇到了以下异常

Illuminate\Database\QueryException : 找不到驱动程序(SQL: select * from information_schema.tables where table_schema = xxx and table_name = xxx)

这是我的 .gitlab-yaml 文件:

image: php:7.2   
services:
  - name: mysql:5.7
variables:
  WITH_XDEBUG: "1"
  DB_HOST: mysql
  DB_USERNAME: root
  MYSQL_USER: root
  MYSQL_ROOT_PASSWORD: xxx
  MYSQL_DATABASE: xxx
stages:
      - build
      - test
building:
  stage: build
  image: php:7.2
  script:
  - cp .env.test .env
  - php artisan config:clear
  - php artisan migrate:refresh
  - php artisan db:seed
  artifacts:
    expire_in: 1 month
    paths:
      - vendor/
      - .env
phpunit:
  stage: test
  image: php:7.2
  script:
    - ./vendor/bin/phpunit --colors --verbose --configuration phpunit.xml

请在下面找到我的 .env.test:

APP_ENV=local
APP_DEBUG=true
APP_KEY=somestring

DB_CONNECTION=mysql
DB_HOST=mysql
DB_DATABASE=xxx
DB_USERNAME=xxx
DB_PASSWORD=xxx

BROADCAST_DRIVER=log
CACHE_DRIVER=file
QUEUE_CONNECTION=sync
SESSION_DRIVER=file
SESSION_LIFETIME=xxx

我做错了什么?我无法解决它。

【问题讨论】:

    标签: php mysql laravel docker gitlab-ci


    【解决方案1】:

    您的服务器缺少Mysql驱动程序,我遇到了同样的错误,我使用以下命令解决了它:

    sudo apt install php7.2-mysql
    

    您可以更换php版本,根据您的服务器php版本,同样一旦完成上述命令,您可以运行以下命令:

    php artisan cache:clear
    php artisan config:clear  
    

    上述命令清除您的服务器缓存并重新启动您的服务器。

    【讨论】:

      猜你喜欢
      • 2019-09-07
      • 1970-01-01
      • 2015-09-11
      • 2021-08-26
      • 2016-12-21
      • 2021-06-12
      • 2020-09-26
      • 2012-12-09
      相关资源
      最近更新 更多