Enabling Mysql 5.6 and PHP on Yosemite

Problem: default mysql from macports does not work anymore on Mac OS X 10.10 Yosemite because of compiler or so it seems.

Solution: install mysql56-server through Macports and mcGyver a plist together to start it everytime you start your mac, code below.

Problem: try to connect to mysqld using a terminal works fine, but in PHP using mysqli object you will get a "PHP Warning: mysqli::mysqli(): (HY000/2002): No such file or directory in ...".

Solution: change to localhost -> doesn't work. Change it back to localhost, does not work either. The problem lies in the mysqld.sock file which is installed in a non-standard location by PHP standards. Open /etc/php.ini in your favorite editor and look for the line mysqli.default_socket. Edit this line to read:


If you installed a plist file for mysqld then you can restart using:

sudo launchctl stop org.macports.mysql56-server.plist

sudo launchctl start org.macports.mysql56-server.plist

All should be fine now, PHP can now access the mysqld using the socket. You may want to change host to localhost in case you were using before.

Note: if you are using PDO mysql you need to use the corresponding socket location option.


<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd" >
<plist version='1.0'>

This article is my 4th oldest. It is 223 words long, and it’s got 0 comments for now.