Php: Could not find any MySQL database drivers. (MySQLi or PDO required.)

Created on 31 Jan 2017  路  2Comments  路  Source: docker-library/php

I'm getting this error by php code on my page

Could not find any MySQL database drivers. (MySQLi or PDO required.)

My custom image is defined as:

FROM php:5.5-apache

ENV TERM=dumb

RUN echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selections; \
    apt-get update; \
    apt-get install -y --no-install-recommends php5-mysql 

I'm sure that PDO is also included into php5-mysql package.
Should I edit some .ini files? If yes, which ?

I tried to find .ini files into my container at run time, but I cannot find the expected php.ini file.

root@b5c26b07717b:/var/www/html# find / -name "*.ini"
/etc/php5/mods-available/opcache.ini
/etc/php5/mods-available/mysqli.ini
/etc/php5/mods-available/mysql.ini
/etc/php5/mods-available/pdo_mysql.ini
/etc/php5/mods-available/pdo.ini
/usr/share/php5/mysql/mysqli.ini
/usr/share/php5/mysql/mysql.ini
/usr/share/php5/mysql/pdo_mysql.ini
/usr/share/php5/common/opcache.ini
/usr/share/php5/common/pdo.ini
/var/lib/ucf/cache/:etc:php5:mods-available:mysqli.ini
/var/lib/ucf/cache/:etc:php5:mods-available:pdo_mysql.ini
/var/lib/ucf/cache/:etc:php5:mods-available:mysql.ini
/var/lib/ucf/cache/:etc:php5:mods-available:pdo.ini
/var/lib/ucf/cache/:etc:php5:mods-available:opcache.ini

image

image

Usinh phpinfo I cannot see mysql and/or PDO for mysql installed...

Most helpful comment

Or, for PDO:

RUN docker-php-ext-install pdo_mysql

All 2 comments

You need to install the driver using docker-php-ext-install like so.

FROM php:5.5-apache

RUN docker-php-ext-install mysqli

Using apt-get install will install the apt package of the extension which is not compatible with the source compile used by the image. Using docker-php-ext-install compiles the ext against the bundled php source and also adds the proper ini files.

Or, for PDO:

RUN docker-php-ext-install pdo_mysql
Was this page helpful?
0 / 5 - 0 ratings