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 127.0.0.1 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:
mysqli.default_socket=/opt/local/var/run/mysql56/mysqld.sock
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 127.0.0.1 before.
Note: if you are using PDO mysql you need to use the corresponding socket location option.
org.macports.mysql56-server.plist
<?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'>
<dict>
<key>Label</key><string>org.macports.mysql56-server</string>
<key>ProgramArguments</key>
<array>
<string>/opt/local/bin/daemondo</string>
<string>--label=mysql56-server</string>
<string>--start-cmd</string>
<string>/opt/local/lib/mysql56/bin/mysqld</string>
<string>--user=_mysql</string>
<string>;</string>
<string>--pid=exec</string>
</array>
<key>Debug</key><false/>
<key>Disabled</key><true/>
<key>KeepAlive</key><true/>
</dict>
</plist>