doushifang4382 2019-03-05 05:16
浏览 84
已采纳

我在gitlab CI中构建我的laravel应用程序时遇到“找不到驱动程序”异常

While building my laravel application using gitlab CI/CD ,I am getting the following exception:

Illuminate\Database\QueryException : could not find driver (SQL: select * from information_schema.tables where table_schema = xxx and table_name = xxx)

Here is my .gitlab-yaml file:

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

Please find my .env.test below:

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

What am I doing wrong? I can't be able to resolve it.

  • 写回答

1条回答 默认 最新

  • dongyan4424 2019-03-05 05:24
    关注

    Mysql driver is missing from your server, I got the same error, I resolved it using the following command:

    sudo apt install php7.2-mysql
    

    You can replace the php version, according to your server php version, Also once done with the above command you can run the following command:

    php artisan cache:clear
    php artisan config:clear  
    

    The above command clear your server cache and restart your server.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥40 复杂的限制性的商函数处理
  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码