If you have Zend Server installed and you have an instance of MySQL that didn’t come with Zend Server, then Zend Studio will try to connect to the one that came with Zend Server. I discovered this the hard way when my PHPUnit tests kept failing in Zend Studio but ran perfectly from the command line (I had PHPUnit installed from PEAR and the one that came with Zend Studio).
So I decided to make Zend Server connect to my default MySQL instance instead of uninstalling Zend Server (because I want to play with it). For those with the same problem, you can do this:
# Rename Zend Studio's socket file to something else # If you didn't choose the default, installation path then # use the path to that location instead mv /usr/local/zend/mysql/tmp/mysql.sock /usr/local/zend/mysql/tmp/mysql_old.sock # My MySQL installation's socket file is located in /tmp # If your's is different, then you will have to modify the source path ln -s /tmp/mysql.sock /usr/local/zend/mysql/tmp