我对PHP世界很陌生。我在我的Mac上安装了MAMP。这是我写的连接到MySQL的代码:MAMP无法连接到PHP脚本中的SQL服务器
<?php
// Connect to the database server
$dbcnx = @mysql_connect("localhost", "root", “root”);
if (!$dbcnx) {
echo("<P>Unable to connect to the " .
"database server at this time.</P>");
exit();
}
?>
MySQL已经启动并正在运行。我不知道为什么我无法连接。
使用'mysql_error()'在你的回声中找到错误。 –
从mysql_connect删除@符号。它将抑制已发生的任何错误。 – CharliePrynn
感谢您的回复......我得到错误访问被拒绝用户'root'@'localhost'(使用密码:是) – user3739866