Database connection error: Access denied to 'ecom' for user on localhost

I just set up a fresh WAMP server but can't get my database to connect. I'm using PHP PDO and keep getting an access denied error. Here's what I've got:

class DBConnect {
    private $host = 'localhost';
    private $db = 'mystore';
    private $user = 'root';
    private $pass = '';
    public $connection;

    function __construct() {
        if (!$this->connection) {
            try {
                $dsn = "mysql:host={$this->host};dbname={$this->db}";
                $this->connection = new PDO($dsn, $this->user, $this->pass);
                $this->connection->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
            } catch (PDOException $e) {
                echo "Connection failed: " . $e->getMessage();
                exit;
            }
        }
    }
}

Any ideas what might be causing this? I've double-checked my database name and login info but still no luck.

Verify that the MySQL service is running on your WAMP server. It may seem active while the MySQL component is not actually started. Check the WAMP icon and ensure all services are green; if that’s not the case, restart MySQL. Additionally, confirm that you have created the ‘mystore’ database, since new installations may not include it by default. Finally, recheck the MySQL root password—even though it’s often blank, a set or forgotten password might be causing the issue.

hey have u tried checkin ur php.ini file? sometimes the mysql extension isnt enabled by default. also make sure ur using the right port for localhost (usually 3306). if that doesnt work maybe try creating a new user with all privleges instead of using root