For me the issue was in the php.ini file. The property mysql.default_socket was pointing to file in a non-existent directory. The property was pointing to
/var/mysql/mysql.sock but in OSX, the file was located in
Once I updated the entry in php.ini and restarted the webserver, the issue was resolved.