Tagged: connect

Mac OS, MySQL: No such file or directory (trying to connect via unix:///

- by admin

Error on attempt to connect locally to MySQL server DB with PHP on MacOS X Lion 10.7:

No such file or directory (trying to connect via unix:///var/mysql/mysql.sock)

Solution 1:

instead of localhost use 127.0.0.1:
mysql_connect ('127.0.0.1', $user, $password);

Solution 2:

In /etc/php.ini change
pdo_mysql.default_socket = /var/mysql/mysql.sock
mysql.default_socket = /var/mysql/mysql.sock
mysqli.default_socket = /var/mysql/mysql.sock

to
pdo_mysql.default_socket = /tmp/mysql.sock
mysql.default_socket = /tmp/mysql.sock
mysqli.default_socket = /tmp/mysql.sock

Do not forget to restart Apache after update :-)

FYI: If no /etc/php.ini found just copy /etc/php.ini.default to /etc/php.ini

« All tags