Quantcast
Channel: WampServer - WampServer English
Viewing all articles
Browse latest Browse all 3177

Uncaught PDOException: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) (1 reply)

$
0
0
1 Windows11 64 bit
2 wampserver3.2.0_x64
3 2.4.41
4 7.3.12
5 8.0.18
6 Green
8 Yes
8a No
9 Yes
10
11 Avira,Windows Defender
12 c:/wamp64
13 127.0.0.1 core
::1 core

I have a fresh install of wamp, set the mysql password, logged into phpmyadmin with that password.
Using 3-tier Presentation->Logic->Data layers.
In a webpage (Presentation) I require_once (Logic.php);
In Logic.php I require_once(Data.php).
In Data.php I have require_once(config.php);
public function __construct()
{
try
{
$conn = new PDO("mysql:host={$host};name={$name}",$user,$pwd),array((PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION));
}
catch (PDOException $e)
{
echo 'ERROR: ' . $e->get_message();
}
}

Config.php:
$user = 'root';
$pwd = 'password';
$dns = 'mysql:host=localhost;dbname=core';
try {
$conn = new PDO($dns, $user, $pwd, array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION));
}
catch (PDOException $e)
{
echo 'Error: ' . $e->getMessage();
}
At the bottom of Data.php I have $pdo = new PDO($dns,$user,$pwd);

Without the require_once, the website displays properly. Can't figure out if the problem is in mysql or php or both. Could it be a configuration issue? Happy to provide any other info.

Viewing all articles
Browse latest Browse all 3177

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>