Did you install pdo_mysql? https://github.com/mlocati/docker-php-extension-installer
Aug 16, 2020
5
Level 5
laravel migration raise could not find driver under docker
Hello, I installed laravel 5.8(with mysql) app under docker with php:7.1-apache and running the migration I got error that could not find driver :
root@3b62eed328c1:/var/www/ticketly_docker_root# php artisan migrate
In Connection.php line 664:
could not find driver (SQL: select * from information_schema.tables where table_schema = public and table_name = migrations and table_type = 'BASE TABLE')
In PDOConnection.php line 31:
could not find driver
In PDOConnection.php line 27:
could not find driver
In my _Docker/web/Dockerfile.yml file I have mysqli, pdo and pdo_mysql installed :
FROM php:7.1-apache
RUN apt-get update && \
apt-get install -y \
python \
libfreetype6-dev \
libwebp-dev \
libjpeg62-turbo-dev \
libpng-dev \
libzip-dev \
nano \
mc \
git-core \
curl \
build-essential \
openssl \
libssl-dev \
libgmp-dev \
libldap2-dev \
netcat \
locate \
&& git clone https://github.com/nodejs/node.git \
&& cd node \
&& git checkout v12.0.0 \
&& ./configure \
&& make \
&& make install
RUN docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-webp-dir=/usr/include/ --with-jpeg-dir=/usr/include/
# Install Composer
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
RUN docker-php-ext-install gd pdo pdo_mysql zip gmp bcmath pcntl ldap sysvmsg exif \
&& a2enmod rewrite
RUN docker-php-ext-install mysqli && docker-php-ext-enable mysqli
COPY virtualhost.conf /etc/apache2/sites-enabled/000-default.conf
Are commands above correct? I complied the project ok.
In .env:
# I tried both variants below after cache clearing. Which of them have I to use ?
DB_CONNECTION=mysqli
# DB_CONNECTION=mysql
DB_HOST=db
DB_PORT=3306
DB_DATABASE=DockerTicketly
DB_USERNAME=docker_user
DB_PASSWORD=4321
Entering the bash I check my current configuration:
# php -v
\PHP 7.1.33 (cli) (built: Oct 25 2019 06:33:10) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2018 Zend Technologies
root@a03a8839fff2:/var/www/ticketly_docker_root# php -m
[PHP Modules]
bcmath
Core
ctype
curl
date
dom
exif
fileinfo
filter
ftp
gd
gmp
hash
iconv
json
ldap
libxml
mbstring
mysqli
mysqlnd
openssl
pcntl
pcre
PDO
pdo_mysql
pdo_sqlite
Phar
posix
readline
Reflection
session
SimpleXML
SPL
sqlite3
standard
sysvmsg
tokenizer
xml
xmlreader
xmlwriter
zip
zlib
Thanks!
Level 102
Your default is pgsql not mysql
Install pdo_pgsql or set it to use mysql instead
1 like
Please or to participate in this conversation.