error: cannot find php_pdo_driver.h while installing pdo_mysql

11,158

Solution 1

You have to build PHP with PDO support.

http://pecl.php.net/package/PDO

"Do not use this, as PDO has been moved into core (the php source) so this pecl extension is dead."

Solution 2

Current PHP comes with PDO extension in its core, but you still need to add support for each database engine you need to connect to.

I had this problem with symfony2 complaning about the lack of pdo_pgsql driver. I looked everywhere on the web and basically concluded that I had to do (in ubuntu)

sudo apt-get install libpq-dev
sudo pecl install pdo_pgsql

But that will fail, basically for the same reason as it failed you (in my case it said configure: error: Cannot find php_pdo_driver.h.)

then, by accident, I found out that you need to install the packages as

sudo apt-get install php5-pgsql
sudo apt-get install php5-mysql

and that will add pdo_pgsql and pdo_mysql to your PDO driver.

In centOS, it should be

sudo yum install php-pgsql
sudo yum install php-mysql
Share:
11,158
Rohith
Author by

Rohith

Updated on June 04, 2022

Comments

  • Rohith
    Rohith almost 2 years

    I want to load pdo_mysql extension to php inorder to install Megento in my VPS (runs CentOS). Then I searched the PHP.ini file for something like "extension=pdo.so ". But I was unable to find such a line in my ini file. Then I tried to install pdo_mysql using "pecl install" . But the installation exits by displaying this error ,

    checking for PDO includes... checking for PDO includes...
    configure: error: Cannot find php_pdo_driver.h.
    ERROR: `/root/tmp/pear/PDO_MYSQL/configure' failed
    

    My phpinfo . Please help me to solve this problem.

  • P Sreedhar
    P Sreedhar over 9 years
    Worked like gem. Thank you.
  • delphirules
    delphirules over 5 years
    I'm having the same error when trying to compile a PDO Dblib driver in Mac Os... What should i do ?
  • ffflabs
    ffflabs over 5 years
    @delphirules the only useful mention I could find was this one: discussions.apple.com/thread/1539743