我已经尝试将我的PHP文件连接到MySQL数据库有一段时间了,现在我正在使用WAMP服务器,但遇到了错误1045,我还设置了一个密码,并尝试了网络上给出的各种设置。
<?php
$link = mysqli_connect("127.0.0.1", "root", "password", "registration");
if (!$link) {
echo "Error: Unable to connect to MySQL." . PHP_EOL;
echo "Debugging errno: " . mysqli_connect_errno() . PHP_EOL;
echo "Debugging error: " . mysqli_connect_error() . PHP_EOL;
exit;
}
echo "Success: A proper connection to MySQL was made! The my_db database is great." . PHP_EOL;
echo "Host information: " . mysqli_get_host_info($link) . PHP_EOL;
mysqli_close($link);
?>以下是我正在运行的代码,注册是数据库,我使用phpmyadmin创建了它
发布于 2020-03-18 16:40:06
<?php
$link = mysqli_connect("127.0.0.1", "root", "", "registration");
if (!$link) {
echo "Error: Unable to connect to MySQL." . PHP_EOL;
echo "Debugging errno: " . mysqli_connect_errno() . PHP_EOL;
echo "Debugging error: " . mysqli_connect_error() . PHP_EOL;
exit;
}
echo "Success: A proper connection to MySQL was made! The my_db database is great." . PHP_EOL;
echo "Host information: " . mysqli_get_host_info($link) . PHP_EOL;
mysqli_close($link);
?>https://stackoverflow.com/questions/60735738
复制相似问题