$db= mysqli_connect('localhost', "root", "root");
if(!$db) die("Error connecting to MySQL database.");
mysqli_select_db("onlineform", $db);
当我尝试连接到如上所示的数据库时,我收到以下错误:
Warning: mysqli_connect(): [2002] No such file or directory (trying to connect
via unix:///var/mysql/mysql.sock) in - on line 3 Warning: mysqli_connect():
(HY000/2002): No such file or directory in - on line 3 Error connecting
to MySQL database.
这是我第一次使用mysqli,我认为这将是对mysql的重大改进。我检查了MAMP是否启用了它。
有什么建议吗?
答案 0 :(得分:0)
检查插座是否正确。如果没有,请覆盖默认套接字。我想你必须在MAMP中尝试这样的事情:
$link = mysql_connect(
':/Applications/MAMP/tmp/mysql/mysql.sock',
'root',
'root'
);