1
votes

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
3

3 Answers

1
votes

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

0
votes

You can use MySQL Workbench to easily change the permissions. Under Server -> User and Privileges. Make host as % for username from which you want to access.

0
votes

Just need update your params in .env file by something like;

DB_HOST= mysql.hostinger.com    
DB_DATABASE=u7979345345_user    
DB_PASSWORD=password    

that info provides u in Control Panel>MySQL Databases from menu

https://www.hostinger.com/how-to/what-is-my-mysql-hostname