php – 警告:mysqli_connect():( HY000 / 1045):用户’用户名’@’localhost’拒绝访问(使用密码:YES)

Warning: mysqli_connect(): (HY000/1045): Access denied for user ‘username’@’localhost’ (using password: YES) in C:\Users\xampp\htdocs\PHP_Login_Script\config.php on line 6

Warning: mysqli_real_escape_string() expects parameter 1 to be mysqli, boolean given in C:\Users\xampp\htdocs\PHP_Login_Script\login.php on line 10

Warning: mysqli_real_escape_string() expects parameter 1 to be mysqli, boolean given in C:\Users\xampp\htdocs\PHP_Login_Script\login.php on line 11

Warning: mysqli_query() expects parameter 1 to be mysqli, boolean given in C:\Users\xampp\htdocs\PHP_Login_Script\login.php on line 15

Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, null given in C:\Users\xampp\htdocs\PHP_Login_Script\login.php on line 16

Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, null given in C:\Users\xampp\htdocs\PHP_Login_Script\login.php on line 19

我在localhost上遇到这个错误,即使我的配置文件是这样的:

<?php

    define("DB_HOST", "localhost");
    define("DB_USER", "root");
    define("DB_PASSWORD", "");
    define("DB_DATABASE", "databasename");

    $db = mysqli_connect(DB_SERVER, DB_USERNAME, DB_PASSWORD, DB_DATABASE);

?>

这曾经有用,但现在已不复存在了.这段代码有问题还是现在不能正常工作? This是我正在进行的教程.

最佳答案
用户名,主机和密码的组合不允许连接到服务器.验证服务器上的权限表(如果需要,重新加载授权)以及您正在连接到正确的服务器.

转载注明原文:php – 警告:mysqli_connect():( HY000 / 1045):用户’用户名’@’localhost’拒绝访问(使用密码:YES) - 代码日志