PHP 7 RC3: How to install missing MySQL PDO

PhpMysqlUbuntuPdoPhp 7

Php Problem Overview

I am trying to setup webserver with PHP 7 RC3 + Nginx on Ubuntu 14.04 (for test purposes).

I installed Ubuntu in Vagrant using ubuntu/trusty64 and PHP 7 RC 3 from Ondřej Surý (

I can not find the way to install MySQL PDO (PHP sees PDO class but not anything related to MySQL, like PDO::MYSQL_ATTR_DIRECT_QUERY etc.)

Looks like there is no lib php7.0-mysql (by analogy with standard php5-mysqlnd and php7.0-fpm etc. from Ondřej)

Section PDO in phpinfo():

PDO support	     enabled
PDO drivers	     no value

How can I get it?

Php Solutions

Solution 1 - Php

For thoses running Linux with apache2 you need to install php-mysql

apt-get install php-mysql

or if you are running ubuntu 16.04 or higher just running the following command will be enought, no need to edit your php.ini file

apt-get install php7.2-mysql

If you are running ubuntu 15.10 or below:

Edit your php.ini file, it's located at /etc/php/[version]/apache2/php.ini and search for pdo_mysql you might found something like this


Change it to this

Save the file and restart apache

service apache2 restart

Check that it's available in your phpinfo()

Solution 2 - Php

First install php-mysql

sudo apt-get install php7.0-mysql
//change the version number based on the php version

then enable the module

sudo phpenmod pdo_mysql

and restart apache

sudo service apache2 restart 

Solution 3 - Php

On ubuntu 18.04 following works for me

type this in your terminal

For php7.3

sudo apt-get install php7.3-gd php7.3-mysql

For php7.0

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

For php5

sudo apt-get install php5-gd php5-mysql

Solution 4 - Php

First, check if your php.ini has the extension enabled "php_pdo_mysql" and "php_mysqli" and the path of "extension_dir" is correct. If you need one of above configuration, then, you must restart the php-fpm to apply the changes.

In my case (where i am using the Windows OS in the company, i really prefer OSX or Linux), i solved the problem putting this values in the php.ini:

; ...

extension_dir = "ext"

; ... 


; ...

I hope this helps.

Solution 5 - Php

Since eggyal didn't provided his comment as answer after he gave right advice in a comment - i am posting it here: In my case I had to install module php-mysql. See comments under the question for details.

Solution 6 - Php

If you are on windows, and your php folder is not in your PATH, you have set the absolute directory in your php.ini

for example:

extension_dir = "C:/php7/ext"

and uncomment


Restart apache2.4 and it should work.

I hope it helps.

Solution 7 - Php

  1. download the source code of php 7 and extract it.
  2. open your terminal
  3. swim to the ext/mysqli directory
  4. use commands: > phpize > >./configure > make > make install (as root)
  5. enable in your php.ini file
  6. done!

This worked for me

Solution 8 - Php

I had, pretty much, the same problem. I was able to see that PDO was enabled but I had no available drivers (using PHP 7-RC4). I managed to resolve the issue by adding the php_pdo_mysql extension to those which were enabled.

Hope this helps!

Solution 9 - Php

I resolved my problem on ubunto 20.4 by reinstalling php-mysql.

Remove php-mysql:

sudo apt purge php7.2-mysql

Then install php-mysql:

sudo apt install php7.2-mysql

It will add new configurations in php.ini

Solution 10 - Php

Had the same issue, resolved by actually enabling the extension in the php.ini with the right file name. It was listed as but the module name in /lib/php/modules was called just

So just remove the "php_" prefix from the php.ini file and then restart the httpd service and it worked like a charm.

Please note that I'm using Arch and thus path names and services may be different depending on your distrubution.

Solution 11 - Php

I'll start with the answer then context NOTE this fix was logged above, I'm just re-stating it for anyone googling.

  1. Download the source code of php 7 and extract it.

  2. open your terminal

  3. swim to the ext/pdo_mysql directory

  4. use commands:




    make install (as root)

  5. enable in your php.ini file

This is logged as an answer from here (please upvote it if it helped you too):

Context: I'm trying to add LimeSurvey to the standard WordPress Docker. The single point holding me back is "PHP PDO driver library" which is "None found"

php -i | grep PDO                                                                                  
PHP Warning:  PHP Startup: Unable to load dynamic library 'pdo_odbc' (tried: /usr/local/lib/php/extensions/no-debug-non-zts-20170718/pdo_odbc (/usr/local/lib/php/extensions/no-debug-non-zts-20170718/pdo_odbc: cannot open shared object file: No such file or directory), /usr/local/lib/php/extensions/no-debug-non-zts-20170718/ (/usr/local/lib/php/extensions/no-debug-non-zts-20170718/ cannot open shared object file: No such file or directory)) in Unknown on line 0
PHP Warning:  Module 'mysqli' already loaded in Unknown on line 0
PDO support => enabled
PDO drivers => sqlite
PDO Driver for SQLite 3.x => enabled

Ubuntu 16 (Ubuntu 7.3.0)

apt-get install php7.0-mysql


Package 'php7.0-mysql' has no installation candidate

Get instructions saying all I have to do is run this:

add-apt-repository -y ppa:ondrej/apache2

But then I get this:

UnicodeDecodeError: 'ascii' codec can't decode byte 0xc5 in position 223: ordinal not in range(128)

So I try and force some type of UTF: LC_ALL=C.UTF-8 add-apt-repository -y ppa:ondrej/apache2 and I get this: no valid OpenPGP data found.

Follow some other instructions to run this: apt-get update and I get this: Err:14 cosmic/main amd64 Packages 404 Not Found Err:15 cosmic/main amd64 Packages 404 Not Found and - I think because of that - I then get:

The repository ' cosmic Release' does not have a Release file.

By this stage, I'm still getting this on apt-get update:

Package 'php7.0-mysql' has no installation candidate.

I start trying to add in php libraries, got Unicode issues, tried to get around that and.... you get the idea... whack-a-mole. I gave up and looked to see if I could compile it and I found the answer I started with.

You might be wondering why I wrote so much? So that anyone googling can find this solution (including me!).

Solution 12 - Php

['class' => 'yii\db\Connection',    'dsn' => 'mysql:host=localhost:3306;dbname=testdb',    'username' => 'user',    'password' => 'password',    'charset' => 'utf8',]

It's simple: Just provide the port number along with the host name and set default sock path to your mysql.sock file path in php.ini which the server is running on.


All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionSmxCdeView Question on Stackoverflow
Solution 1 - PhpAngel115View Answer on Stackoverflow
Solution 2 - PhpStateLessView Answer on Stackoverflow
Solution 3 - PhpSujeet malviView Answer on Stackoverflow
Solution 4 - PhpJoão Paulo CercalView Answer on Stackoverflow
Solution 5 - PhpSmxCdeView Answer on Stackoverflow
Solution 6 - Phpuser1455180View Answer on Stackoverflow
Solution 7 - PhpmiclView Answer on Stackoverflow
Solution 8 - PhpjgadrowView Answer on Stackoverflow
Solution 9 - PhpBABAK ASHRAFIView Answer on Stackoverflow
Solution 10 - PhpXorifelseView Answer on Stackoverflow
Solution 11 - Phpuser3912517View Answer on Stackoverflow
Solution 12 - PhpDhanush-ucView Answer on Stackoverflow