MAMP找到MySql,但我的网页没有

时间:2012-03-28 19:24:39

标签: mysql macos mamp

我的网页为此Mac OSX 10.6.6,MAMP设置的mysql_connect()调用返回错误。

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`

当我回显mysql_connect()的主机,用户名和密码时,它们与MAMP首选项'localhost:8889', 'root', 'password'

相同

为什么mysql_connect无法访问数据库?

1 个答案:

答案 0 :(得分:1)

找到当前的php.ini文件(运行包含以下内容的脚本并搜索该位置)并将袜子更改为mamp-sock:

mysql.default_socket = /Applications/MAMP/tmp/mysql/mysql.sock

如果出现更多var / mysql / mysql.sock,也可以更改它们。