[英]MySQL error: SQLSTATE[HY000] [1045] Access denied for user 'test'@'localhost' (using password: YES)
I'm actually making a form in PHP with MVC2. 我实际上是使用MVC2在PHP中制作表单。 In my model, I need to connect to a local MySQL database.
在我的模型中,我需要连接到本地MySQL数据库。 I do this with PDO.
我使用PDO进行此操作。 Here is my dsn :
这是我的dsn:
mysql:host=localhost;dbname=test-heia;charset=utf8mb4', "test", "test"
But when I try to access my model through Chrome, I got this error (with PDOException) : 但是,当我尝试通过Chrome访问我的模型时,出现了此错误(带有PDOException):
SQLSTATE[HY000] [1045] Access denied for user 'test'@'localhost' (using password: YES)
SQLSTATE [HY000] [1045]用户'test'@'localhost'的访问被拒绝(使用密码:是)
I'm sure of the user/password. 我确定用户名/密码。 I also tried with root user, but it doesn't seems to work.
我也尝试了root用户,但似乎不起作用。
It's not like the proposed answer, because it's on a web page :) 它不像建议的答案,因为它在网页上:)
Could you please help me ? 请你帮助我好吗 ? Thank you in advance :)
先感谢您 :)
define('DBHOST', 'localhost');
define('DBUSER', 'test');
define('DBPASS', 'test');
define('DBNAME', 'test');
try {
$bd= new PDO('mysql:host='.DBHOST.';dbname='.DBNAME,DBUSER,DBPASS);
}catch(Exception $e)
{
die('Erreur : '.$e->getMessage());
}
Try it with that 尝试一下
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.