Symfony 3 dont find pdo_mysql driver

Asked at 2017-01-11 21:07:18Z
  • 5 Subscribers

My symfony project do not find pdo_mysql driver. I am using debian server. The same config works on OSX ok but not here. When I use php -m command it show driver and also the php -i |grep pdo_mysql show:

API Extensions => mysqli,pdo_mysql
pdo_mysql.default_socket => /var/run/mysqld/mysqld.sock =>     /var/run/mysqld/mysqld.sock

This is my symfony configuration and paramters:

database_port: 3306
database_name: bisol_time
database_user: root
database_password: root


    driver:   pdo_mysql
    host:     "%database_host%"
    port:     "%database_port%"
    dbname:   "%database_name%"
    user:     "%database_user%"
    password: "%database_password%"
    charset:  UTF8

So what can i do. I try everything and read every topic under this problem but i do not find the solution. Can anyone help me?

2 answers in total

Stepashka Posted at 2017-01-11 21:42:13Z

This is not related to the Symfony but for the system setup.

As you can see when you run PHP in CLI it uses the config from /etc/php/7.0/cli/conf.d/20-pdo_mysql.ini (notice the cli in the path). While when used by Apache it uses most likely /etc/php/7.0/apache2/conf.d/20-pdo_mysql.ini or similar.

You can either nevigate to /etc/php/7.0/ or create info.php with <?php phpinfo(); and see where the config files are.

It seems that in that PHP configuration for apache the driver is not installed.

Alvin Bunk Posted at 2017-01-11 21:48:39Z

I believe there is a different pdo for PHP 5. On my system (CentOS 6) I have php70u-pdo.i686. I checked by using yum list installed |grep pdo. I can't guide you to install on OSX, I suspect you need to use brew, but check to see if you can install pdo for PHP7 and enable it in your php.ini file.

That sounds like the problem.

EDIT # 2 Based on Comments

Can you try:

apt-get install php7.0 php7.0-mysql

I think the mysql installs pdo as well. Try it. not sure if it will work.

Answer this questsion