PHP 警告: mysqli_connect(): (HY000/2002): 连接被拒绝
我正在使用PHP 5.5和MAMP(从这里下载):
我有一个像这样的基本脚本:
<?php
$servername = "127.0.0.1";
$username = "root";
$password = "root";
// Create connection
$conn = mysqli_connect($servername, $username, $password);
// Check connection
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}
echo "Connected successfully";
?>
当我运行这个脚本时,我得到这个错误:
PHP Warning: mysqli_connect(): (HY000/2002): Connection refused in /Applications/MAMP/htdocs/test/test.php on line 7
是否需要在 MAMP 或 PHP 中设置一些配置问题?