Installing PDO_MYSQL on PHP 5.1.6 using PECL OS: U

2019-02-06 23:13发布

问题:

I'm having real problems getting PDO_MYSQL working.

I started by just trying to install the PDO_MYSQL driver via PECL, however when this didn't work I looked round to see if there where any issues reported. It seems that there may be a conflict between the embedded version of PDO and PDO_MYSQL. To that end i decided to reinstall all it's dependencies from PECL.

Environment:

OS: Ubuntu
PHP Ver: 5.1.6 (Unable to upgrade due to clients live environment)

Procedure Followed:

PECL uninstall PDO_MYSQL
PECL uninstall PDO
PECL uninstall mysql
PECL install mysql
PECL install PDO
PECL install PDO_MYSQL

Lines Added to PHP.ini
extension=mysql.so
extension=pdo.so
extension=pdo_mysql.so

apachectl restart
[warn] php5_module is already loaded, skipping

I then check PHPINFO to see which modules are installed. I see:

PDO drivers     sqlite2 

That's it!

If any one could suggest any solutions to this I'd be deeply grateful. I need MYSQL PDO driver to run zend framework for an upcoming project... and yes I have to use v1.6 due to the PHP version.

回答1:

If you're on ubuntu, try apt-get :

sudo apt-get install php5-mysql

which should make

/usr/lib/php5/20060613+lfs/pdo.so

and PDO will be available after an apache restart



回答2:

To anyone having problems with this ensure that the 'libmysqlclient15-dev' library is installed:

sudo apt-get install libmysqlclient15-dev

Then use:

sudo apt-get install pdo_mysql

Without the 'libmysqlclient15-dev' library you'll have problems with pdo.

Found these pages to be quite helpful:

http://pecl.php.net/bugs/bug.php?id=12141
http://ubuntuforums.org/showthread.php?t=474152