Swader
Swader

Reputation: 11597

Native PHP / Mysql installation on Mac, activating the PDO driver

I have a custom installation on the MacOSX Lion consisting of the following:

  1. Native PHP upgraded to 5.4, works like a charm.
  2. Installed MySQL, being run from /usr/local/mysql-5.5.25-osx10.6-x86_64/bin/mysql, works like a charm, Workbench connects and can do ops.
  3. Edited php.ini in /etc/ to activate the following:

    extension=php_mysqli.so
    extension=php_pdo_pgsql.so
    extension=php_pdo_mysql.so
    
  4. 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:

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

Answers (1)

Swader
Swader

Reputation: 11597

The solution was to do the following:

  1. Change .sock path in php.ini to reflect the actual path
  2. Restart your computer, not just apache

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

Related Questions