Skip navigation
This discussion is archived

How to enable PDO_MYSQL in 5.2.4 PHP included into Leopard

23181 Views 17 Replies Latest reply: Apr 8, 2009 11:57 AM by coyotesf RSS
1 2 Previous Next
ValGor Level 1 Level 1 (0 points)
Currently Being Moderated
Oct 28, 2007 7:57 AM
I get it all working but getting an error:
uncaught exception 'PDOException' with message 'could not find driver'.

It looks like there is no PDO-MYSQL in phpinfo configuration list.

On dreamhost (and on my old tiger):
PDO support enabled
PDO drivers sqlite2, sqlite, mysql

PDO Driver for MySQL, client library version 5.0.16

on Leopard:
PDO support enabled
PDO drivers sqlite2, sqlite

Mac OS X (10.5)
  • stewey Level 1 Level 1 (5 points)

    I ran into this also. Oversight on behalf of Apple not to include MySQL PDO drivers. The quickest and dirtiest way I found to get past this is to install Marc Liyanage's PHP distribution for Apache 2. Out of the box this WON'T WORK. You have to move some files around.

    1. Move Apple's php module out of the way.
    sudo mv /usr/libexec/apache2/ \

    2. Move Marc's php module in.
    sudo mv /usr/local/php5/ \

    3. Create the following folder:

    4. Copy libexpat.0.dylib to the above folder.
    This file comes as part of the Developer Tools (among other
    things), so if you have Xcode installed, you should be able
    to copy it from here:

    5. Kick Apache
    sudo apachectl configtest
    sudo apachectl restart

    Hope that works for you too.
  • dicabrio Level 1 Level 1 (0 points)

    There are a lot of people who ran into this. So I was searching for a solution I saw this post and another on When I try this solution Everything works and is loaded with the pdo_mysql driver. But the problem now is that when looking with phpinfo() the MYSQL_SOCKET is still on /tmp/mysql.sock. As I've found out this should be /var/mysql/mysql.sock.

    When trying to connect with mysql with pdo I get an error
    SQLSTATE[HY000] [2002] Can't connect to local MySQL server through socket '/tmp/mysql.sock'

    Does anybody know a solution for this.
  • windhamd Level 1 Level 1 (0 points)
    i got these errors when i switched them out...
    bash-3.2# apachectl restart
    bash-3.2# apachectl configtest
    httpd: Syntax error on line 114 of /private/etc/apache2/httpd.conf: Cannot load /usr/libexec/apache2/ into server: dlopen(/usr/libexec/apache2/, 10): no suitable image found. Did find:\n\t/usr/libexec/apache2/ no matching architecture in universal wrapper
    Mac Pro - Macbook Pro, Mac OS X (10.5.1)
  • windhamd Level 1 Level 1 (0 points)
    and i believe it is something to do with the 64 bit architecture on the G5.. I could not duplicate the error on my intel macbook.
    G5 - Macbook Pro, Mac OS X (10.5.1)
  • windhamd Level 1 Level 1 (0 points)
    ps.... don't do this without a backup of the ... and it doesn't work on leopard on a G5 with 64 bit architecture
    g5 - Macbook Pro, Mac OS X (10.5.1)
  • Rodney Gracia Level 1 Level 1 (15 points)
    So is there a solution to this? Have any of you guys been able to get this running? I need to test Habari blog on my mac dev env and have the same issue.
    160gb MBP, Intel Core 2 Duo, 2.4Ghz, 4GB Ram, Mac OS X (10.5.1)
  • elpepelucho Level 1 Level 1 (0 points)
    actually I'm getting this exact error on my new mbp ...

    anybody have a solution yet that doesn't involve re-compiling anything ?

    I need this for work pretty bad and don't have the time to fiddle with compilations.
    macbook pro, Mac OS X (10.5)
  • barleyblue Level 1 Level 1 (0 points)
    I'm having the exact same problem as you. As far as I can tell, the only way to enable PDO_MYSQL in PHP is by recompiling with appropriate configuration options.

    Like you, I'm not sure how to do this and would appreciate a simple explanation of how to :

    1) Locate the PHP binaries (I'm using PHP 5.2.5)
    2) Do the unix stuff to recompile with the appropriate configuration options.

    If anyone can help someone who is very rusty when it comes to unix I'd really appreciate it.
    MacBook, Mac OS X (10.5.2), PHP 5.2.5
  • lee Perry Level 1 Level 1 (0 points)
    Is there a resolution to this without resorting to rebuilding PHP/Apache and Mysql. This is something that should be addressed with an update from apple allowing for the default versions of php etc to be used. I just got my mbp with the sole purpose of developing in PHP which is what I do for a living, so far its been no use (£1300 paper weight). Not being funny but it really is all it will be used for. I just spent seven hours looking for a solution to this problem and from what I can see a lot of other people have spent even longer. I must admit I'm gutted I cant use it, I look forward to getting a solution to this
    I just hope it doesn't take too long. I use pdo_mysql and the gd extensions, I just migrated from windows which has an excellent php installer that allows extensions to be added and removed at will. This is what we need for the Mac.
    MacBook Pro, Mac OS X (10.5.2)
  • boldfysh Level 1 Level 1 (15 points)
    I have managed to get PDO with MySQL support.

    I installed the latest Marc Liyanage Beta from here: 832dc0

    sudo mv /usr/local/php5 ~/Desktop/php5.old
    curl -O
    tar -xzf php5-*-beta.tar.gz
    sudo mv php5 /usr/local/
    sudo chown -R root:admin /usr/local/php5
    sudo ln -sf /usr/local/php5/entropy-php.conf /etc/apache2/other/+entropy-php.conf

    then comment the existing php module in httpd.conf
    #LoadModule php5_module libexec/apache2/
    the entropy build adds a conf to 'other' if you install it as above, that loads the module from the /usr/local/php5 directory

    (I did it this way so future upgrades are easier and the built in php remains untouched)

    enable the php.ini in /usr/local/php5/lib/

    edit the msyql socket connections there.
    mysql.default_socket = /var/mysql/mysql.sock

    (because I'd previously followed these instructions: 05/)

    restart Apache

    *watch out for short php tags* - they're disabled in this php build.

    the final workaround I had to do for PDO to work properly was to include the socket in the connection string:
    new PDO("mysql:host=localhost;dbname=test;unixsocket=/path/to/socket/found_in_php.ini_ormy.cnf",'username','password');

    I now have a working PHP installation with support for PDO and a bunch of other libraries on OSX 10.5.3 on a Mac Pro (2x2.66 Dual-Core)

    Hope this helps someone (and I didn't leave out any steps)
    Mac Pro, Mac OS X (10.5.3)
  • boldfysh Level 1 Level 1 (15 points)
    Further to the above - messing with the MySQl socket location is a bad idea.

    better to leave it where it is (don't edit /etc/my.cnf) just edit the php.ini to point to where leopard wants its MySQL socket. /tmp/mysql.sock and then you won't have to worry about PDO_MYSQL not finding it, nor Perl modules etc.

    Mac Pro, Mac OS X (10.5)
  • jyothirmayee Level 1 Level 1 (0 points)
    Thanks much. I spent whole day trying all the other options mentioned here and elsewhere. This works very well and straight forward.
    Macbook, Mac OS X (10.5.4), Intel 32 bit
  • dkoo761 Level 1 Level 1 (0 points)
    Hi there,

    I had Apache2/PHP5 working just fine with Leopard, but needed the PDO_mysql extension so decided to give Marc's PHP5 module a try.

    I tried the following steps but now my Apache2 server is totally dead. Won't even serve up a static image file I'm wondering if it's because before running the installer, I didn't see the note about commenting out the line in my httpd.conf file which loads However, I commented that line out AFTER running the installer, but it still didn't work. Also tried re-running the installer again after commenting that line out, but still no luck.

    If I go back into my httpd.conf and uncomment the line, everything works fine with my old PHP5, but that doesn't really get me any farther ahead

    Here are the steps I followed:

    1. cd /usr/local
    2. sudo curl -O
    3. sudo tar -xzf entropy-php-5.2.4-1-apache2.tar.gz
    4. double-clicking entropy-php.mpkg and following the instructions

    Marc's instructions seem to be for 10.4, so I'm wondering if I need to do anything special to get it to work on 10.5?

    Thanks everyone!
    MacBook Gen3, Mac OS X (10.5.5)
  • dkoo761 Level 1 Level 1 (0 points)
    UPDATE: In Googling around, it looks like Marc's PHP module doesn't work on Leopard. Bummer....I guess it's off to the MAMP world. Or perhaps sucking it up, getting off my lazy arse and compiling PHP from source
    MacBook Gen3, Mac OS X (10.5.5)
1 2 Previous Next


More Like This

  • Retrieving data ...

Bookmarked By (0)


  • This solved my question - 10 points
  • This helped me - 5 points
This site contains user submitted content, comments and opinions and is for informational purposes only. Apple disclaims any and all liability for the acts, omissions and conduct of any third parties in connection with or related to your use of the site. All postings and use of the content on this site are subject to the Apple Support Communities Terms of Use.