Reputation: 11597
I have a custom installation on the MacOSX Lion consisting of the following:
Edited php.ini in /etc/ to activate the following:
extension=php_mysqli.so
extension=php_pdo_pgsql.so
extension=php_pdo_mysql.so
phpinfo() says the following:
PDO
PDO support enabled PDO drivers mysql, pgsql, sqlite
pdo_mysql
PDO Driver for MySQL enabled Client API version mysqlnd 5.0.10 - 20111026 - $Id: b0b3b15c693b7f6aeb3aa66b646fee339f175e39 $
Directive Local Value Master Value pdo_mysql.default_socket /var/mysql/mysql.sock /var/mysql/mysql.sock
That means it works, yes?
Two problems though:
No such file as /var/mysql/mysql.sock, it's in /tmp/mysql.sock. But I configured and built php with the PDO options on: --with-mysql=mysqlnd --with-mysqli=mysqlnd --without-pear --with-pdo-mysql=mysqlnd --with-mysql-sock=/var/mysql/mysql.sock. No effect if I change the ini setting to /tmp/mysql.sock, it's reflected in php.ini, but the error stays exactly the same.
When I try to instantiate the PDO class inside PHP, this happens: Uncaught exception 'PDOException' with message 'could not find driver'
When I try accessing MySQL from PHP in an old school mysqli kind of way, I get this:
Failed to connect to MySQL: (2002) No such file or directory Warning: main(): Couldn't fetch mysqli in...
What else can I try to make my PHP and my MySQL play nice?
Upvotes: 4
Views: 16888
Reputation: 11597
The solution was to do the following:
It appears the php.ini changes did not load while doing
$ sudo apachectl restart
and needed the Macbook to reboot before it took them into account.
Upvotes: 6