Rich Buggy

...Developer, CTO, Entrepreneur

Installing PDO for PHP5 on Ubuntu

Written by Rich on February 19th, 2007

For some reason there aren’t any PDO packages for PHP 5 on Ubuntu 6.10. They’re pretty easy to install from PECL but you might need to install the dev version of your database client libraries. Below is what I had to type to install PDO with the MySQL driver.

% sudo apt-get install libmysqlclient15-dev
% sudo pecl install pdo
% sudo pecl install pdo_mysql

You then need add the following to the end of your php.ini file(s). Depending on which version of PHP you installed they’ll be /etc/php5/apache2/php.ini, /etc/php5/cgi/php.ini and /etc/php/cli/php.ini.

extension=pdo.so
extension=pdo_mysql.so

Update: Before you can install any PECL extensions you need to install the php5-dev package. For information see my post about Using PECL with Ubuntu.

5 Comments so far ↓

  1. Meint says:

    I’m getting “ERROR: `phpize’ failed” with
    “sudo pecl install pdo” and
    “sudo pecl install pdo_mysql”

    This is my full log:

    mspan@baksteen:~$ sudo pecl install pdo
    downloading PDO-1.0.3.tgz …
    Starting to download PDO-1.0.3.tgz (52,613 bytes)
    ………….done: 52,613 bytes
    12 source files, building
    running: phpize
    sh: phpize: command not found
    ERROR: `phpize’ failed
    mspan@baksteen:~$ sudo pecl install pdo_mysql
    downloading PDO_MYSQL-1.0.2.tgz …
    Starting to download PDO_MYSQL-1.0.2.tgz (14,778 bytes)
    …..done: 14,778 bytes
    downloading PDO-1.0.3.tgz …
    Starting to download PDO-1.0.3.tgz (52,613 bytes)
    …done: 52,613 bytes
    12 source files, building
    running: phpize
    sh: phpize: command not found
    ERROR: `phpize’ failed
    7 source files, building
    running: phpize
    sh: phpize: command not found
    ERROR: `phpize’ failed

    I use ubuntu 6.06 LTS with php 5.1.4 (and like it a lot!)

  2. Rich says:

    @Meint Thanks for the response. You need to install the php5-dev package first. I’ve updated this post and written a new post about using PECL with Ubuntu/

  3. smiley says:

    I hava a prob too. I want to use pgsql instead of mysql.How can I have php_pdo_pgsql.so that can i put in my php.ini, so i can run my project.pls help me to solve this prob.

    Tanx in advance,
    Smiley

  4. smiley says:

    how about in pgsql? I am using pgsql for my database. I had installed pdo using pecl, then I added extension=pdo.so in my php.ini.When I restart my apache and browse my localhost there is a
    Fatal error: Class ‘PDO’ not found in /var/www/repos/php_iTranscribe-admin/db.inc on line 21
    displayed in my browser.

    Anybody help me to solve this..

    Version of my ubuntu is 6.10
    php is 5.1.6
    apache 2

    Thank you in advance.

    cheers,
    Smiley

  5. [...] 源头 整个 Yo2 上的相关文章:M1710上装ubuntu(续) 在Ubuntu上装VMtools的痛苦经历 7 种流行 PHP IDE 的比较(转) T恤DIY 这几天不顺啊~ printYo2FavControl(“”,”",”ubuntu 上装 php-pear”,”前提 sudo apt-get install apache2 php5 php5-dev 等等 sudo apt-get install libmysqlclient15-dev sudo pecl install pdo sudo pecl install pdo_mysql 说明 phpize 是 php5-dev 中的一个程序,所以如果你看到 ERROR: `phpize’ failed 表示你没有安装 php5-dev 源头 整个 Yo2 上的相关文章:M1710上装ub”);最近阅读过此文章的网友: [...]

  6. Mike says:

    Please update this article, because it shows up among the first Google search results for “php mysql PDO”.

    `sudo pecl pdo` will fail because PDO is not longer maintained.

    `sudo pecl install pdo_mysql` is also likely to fail. See http://www.theatons.com/ubuntu-install-php5-mysql-apache2-ssl-pdo-pdo_mysql#comment-974.

You must be logged in to post a comment.