gpt4 book ai didi

php - Web 托管 - 用户 'username' @'localhost' 的访问被拒绝(使用密码 : NO)

转载 作者:行者123 更新时间:2023-11-30 22:57:32 24 4
gpt4 key购买 nike

我在 HostGator 上上传我的网站,但我的 MySql 有问题,我得到这个错误:

Access denied for user 'hostgatoruser'@'localhost' (using password: NO)

这是我的 php 代码:

try
{
$DB = new PDO('mysql:host=localhost;dbname=hostgatoruser_database', 'hostgatoruser_abc', '********');
}
catch(Exception $e)
{
die('Erreur : '.$e->getMessage());
}

为什么错误告诉我 Access denied for user "hostgatoruser@localhost" 而不是 "hostgatoruser_abc"?如何解决?

编辑:好的,问题是由 mysql_real_escape_string 函数引起的,所以我删除了它们。我仍然不知道为什么我不能使用 mysql_real_escape_string...

最佳答案

除了这里的一些评论建议您检查您的用户名/密码外,还值得检查用户是否已获得对该特定数据库授予的权限。

您可以通过运行找到您被授予的权限:

SHOW GRANTS FOR 'hostgatoruser'@'localhost';

关于php - Web 托管 - 用户 'username' @'localhost' 的访问被拒绝(使用密码 : NO),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25648237/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com