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

我在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.

图片转代码服务由CSDN问答提供 功能建议

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

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

这是我的.gitlab-yaml文件:

  image:php:7.2 
services:  
  - 名称: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 \  n  -  php artisan db:seed 
 artifacts:
 expire_in:1个月
路径:
  -  vendor / 
  -  .env 
phpunit:
 stage:test 
 image:php:7.2 
脚本:  
  -  ./vendor/bin/phpunit --colors  --verbose --configuration phpunit.xml 
   
 
 

请在下面找到我的.env.test: <预> <代码> APP_ENV =本地 APP_DEBUG =真 APP_KEY = somestring DB_CONNECTION = MySQL的 DB_HOST = MySQL的 DB_DATABASE = XXX DB_USERNAME = XXX DB_PASSWORD = XXX BROADCAST_DRIVER = LOG CACHE_DRIVER =文件\ nQUEUE_CONNECTION = sync SESSION_DRIVER = file SESSION_LIFETIME = xxx

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

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

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.

    点赞 打赏 评论

相关推荐 更多相似问题