This question already has an answer here:
这个问题在这里已有答案:
- access denied for user @ 'localhost' to database '' [closed] 2 answers
- 访问被拒绝用户@'localhost'到数据库''[关闭] 2个答案
- Warning: mysqli_connect(): (HY000/1045): Access denied for user 'username'@'localhost' (using password: YES) 16 answers
- 警告:mysqli_connect():( HY000 / 1045):访问被拒绝用户'用户名'@'localhost'(使用密码:是)16个答案
here is my code :
这是我的代码:
<?php
$servername = "XXXXXXXXX";
$username = "XXXXXXXX";
$password = "XXXXXXXXX";
$conn = mysqli_connect($servername, $username, $password);
// Check connection
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}
echo "Connected successfully";
?>
and here is the error
Warning: mysqli_connect() [function.mysqli-connect]: (28000/1045): Access denied for user 'rgwyatt_loganf'@'192.185.46.82' (using password: YES) in /home4/rgwyatt/public_html/loganf/test.php on line 14 Connection failed: Access denied for user 'rgwyatt_loganf'@'192.185.46.82' (using password: YES)
这是错误警告:mysqli_connect()[function.mysqli-connect] :( 28000/1045):/ home4 / rgwyatt / public_html中用户'rgwyatt_loganf'@'192.185.46.82'(使用密码:YES)拒绝访问第14行/loganf/test.php连接失败:用户'rgwyatt_loganf'@'192.185.46.82'拒绝访问(使用密码:YES)
1 个解决方案
#1
1
It is probably a permissions problem. Double check that the ip, user name and password (if required) are correct. If you are trying to connect from a different ip, maybe you don't have permission for your ip.
这可能是权限问题。仔细检查ip,用户名和密码(如果需要)是否正确。如果您尝试从不同的IP连接,也许您没有权限使用您的IP。
Also notice that the error you have posted gives away the ip user name and password.
另请注意,您发布的错误会泄露ip用户名和密码。
And if you are trying to connect to a specific DB, then you are missing the db parameter.
如果您尝试连接到特定的数据库,那么您将缺少db参数。
It should be like this:
它应该是这样的:
$con=mysqli_connect($servename,$username,$password,$db);
#1
1
It is probably a permissions problem. Double check that the ip, user name and password (if required) are correct. If you are trying to connect from a different ip, maybe you don't have permission for your ip.
这可能是权限问题。仔细检查ip,用户名和密码(如果需要)是否正确。如果您尝试从不同的IP连接,也许您没有权限使用您的IP。
Also notice that the error you have posted gives away the ip user name and password.
另请注意,您发布的错误会泄露ip用户名和密码。
And if you are trying to connect to a specific DB, then you are missing the db parameter.
如果您尝试连接到特定的数据库,那么您将缺少db参数。
It should be like this:
它应该是这样的:
$con=mysqli_connect($servename,$username,$password,$db);