My web page returns an error for the calls to mysql_connect() for this Mac OSX 10.6.6, MAMP setup.
Warning: mysql_connect(): [2002] No such file or directory (trying to connect via unix:///var/mysql/mysql.sock) in /Library/WebServer/Documents/index.php on line 51
Warning: mysql_connect(): No such file or directory in /Library/WebServer/Documents/index.php on line 51 Could not connect to database, check database credentials in config.php`
When I echo the host, username, password for mysql_connect() they are the same as the MAMP preferences 'localhost:8889', 'root', 'password'
Why can’t mysql_connect access the database?
Find the current php.ini file (run a script containing: and search for the location) and change the sock to the mamp-sock:
If there are more occurrences of var/mysql/mysql.sock, change them as well.