这个问题在这里已经有答案了:
mysqli::mysqli():(hy000/2002):无法通过套接字“mysql”连接到本地mysql服务器(2)(4个答案)
无法建立连接,因为目标计算机主动拒绝它(10个答案)
两年前关门了。
我得到这个错误。不知道为什么。刚刚安装了xampp。我的代码是:
<?php
$servername = "localhost";
$username = "root";
$password = "";
// Create connection
$conn = new mysqli($servername, $username, $password);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
echo "Connected successfully";
?>
1条答案
按热度按时间muk1a3rh1#
我知道答案了。在使用sql时,我只需要打开mysql\u start.bat文件。