mysqllaravelshared-hosting

SQLSTATE[HY000] [1045] Access denied for user 'qualitym_yaseen'@'localhost' (using password: YES)


I have created an application in Laravel and completed it using a localhost MySQL database. When I was using a localhost XAMPP database, my application worked perfectly but, when I deployed my Laravel application on a newly purchased shared hosting and created a database in cpanel and created a user against that database with all privileges, it throws the error:

SQLSTATE[HY000] [1045] Access denied for user 'qualitym_yaseen'@'localhost' (using password: YES)"

I have tried all possible solution but none worked.

This is my database connection in .env file:

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=qualitym_medicare
DB_USERNAME=qualitym_yaseen
DB_PASSWORD=password

Solution

  • 1) From the Cpanel -> Remote MYSQL -> Copy Access hosts ip > Add it to Access host -> add host

    2) Once the IP is successfully added, paste it to the DB_HOST

    Voila, your connection will work