我尽我所能,永远不要使用php,因为我不熟悉它我有一个问题,我不明白在这里我已经尝试了一些东西,包括不包括在/ config中将表引用改为从localhost作为mysql主机等。用PHP连接数据库时出错
它可能是非常明显的东西,但我只是没有发现它!我去与出来说所有的数据库凭据是完全正确的(我可以用它精美的斯卡拉和Python连接)这里 安韦的错误(真实的用户名/密码不存在OFC)
Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[42000] [1044] Access denied for user 'username'@'10.1.1.43' to database 'a5555413_AudioPl.users'' in /home/a5555413/public_html/drive/auth_handler.php:153 Stack trace: #0 /home/a5555413/public_html/drive/auth_handler.php(153): PDO->__construct('mysql:host=mysq...', 'username...', 'passwd') #1 /home/a5555413/public_html/drive/auth_handler.php(74): AuthHandler->GetDbConnection() #2 /home/a5555413/public_html/drive/index.php(47): AuthHandler->AuthHandler('webui') #3 {main} thrown in /home/a5555413/public_html/drive/auth_handler.php on line 153
连接代码常量的是在一个单独的配置文件
function GetDbConnection() {
$dbh = new PDO(Config::DB_PDO_CONNECT,
Config::DB_PDO_USER,
Config::DB_PDO_PASSWORD);
$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$dbConnection = $dbh;
return $dbConnection;
}
您可能想要链接您用于连接的代码(无用户/密码,ofcourse)。 – ccKep
在我看来,您用于此操作的用户没有所需的权限? – Sander
[访问拒绝用户@'本地主机'到数据库''](http://stackoverflow.com/questions/8621649/access-denied-for-user-localhost-to-database) – hakre