Laravel Cpanel error :SQLSTATE[HY000] [1045] Access denied for user 'homeimpr_clranke'@'localhost' (using password: YES)
Asked Answered
D

7

5

My env file as follow:

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=admin_clrank
DB_USERNAME=admin_clranke
DB_PASSWORD=admin@123

i am getting the error and i have checked the username and password that are same.My website is in cpanel. config.php file is also delted.

Dialytic answered 20/11, 2017 at 8:4 Comment(8)
Have you assigned user to the database in cPanel? And also try password within double quotes e.g. "homeimpr@123"Loaf
yes..i have assigned and same after adding double quotesDialytic
Seems to me it's most likely just a typo somewherePseudohemophilia
i have checked many times..all the values are correctDialytic
is after changes in env file in cpanel does i have to do anything?Dialytic
Generally no... unless you are FTP'ed in via the 'root' user?Pseudohemophilia
Have you checked that you are using env('DB_PASSWORD') in password in config/database.php** ?Loaf
i have created new user..but in error it is showing the old one...is any cache in laravel in cpanel?Dialytic
M
26

Try to use username and password as follows with quotation. i have no idea how it worked, but it really worked for me after searching a lot.

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=admin_clrank
DB_USERNAME='admin_clranke'
DB_PASSWORD='admin@123'
Mutinous answered 23/10, 2019 at 19:16 Comment(3)
this is fully tested and confirmed as working. anyone can try out this way if your ways are not working.Mutinous
you save my lifeMatabele
Great thanks, i always would run this in Cpanel and Plesk, good to find a quick pro!Rhearheba
M
6

it can be fixed by adding a ' single quote on database user and password

DB_DATABASE=admin_clrank
DB_USERNAME='admin_clranke'
DB_PASSWORD='admin@123'

like this. it will work fine for me

Menard answered 9/11, 2020 at 21:23 Comment(0)
O
3

1- Add single quote ' in username and password

2- Then add this route in your web app and open it from browser:

Route::get('/cleareverything', function () {
    
    $clearcache = Artisan::call('cache:clear');
    echo "Cache cleared<br>";

    $clearview = Artisan::call('view:clear');
    echo "View cleared<br>";

    $clearconfig = Artisan::call('config:cache');
    echo "Config cleared<br>";

});
Oliy answered 26/12, 2020 at 17:9 Comment(0)
Q
2

Use console and artisan:

php artisan config:cache

This will clear cache configuration and then new settings will work.

Quizzical answered 20/11, 2017 at 8:37 Comment(1)
Use console. The same way u use: php artisan serveQuizzical
R
1

Steps to debug:

  • check if you have .env file in server/cpanel usually we don't publish .env files on server, if you have .env file then the username in your .env file and in error is different. Looks like database configuration is inside your config/database.php file.
  • check if database credentials in config/database.php file is correct
  • if nothing works create new database and user and then change your db credential in .env file if you are using .env else update credential in config/database.php file...
Rephrase answered 20/11, 2017 at 8:34 Comment(2)
added new user and new db..but nothing happen! is their any cache prblm in cpanel?Dialytic
Did you followed all above steps? If yes and still not working then there might be issue with cache. Try clearing cache, you may need terminal access for that.Rephrase
K
1

change DB_HOST to localhost and run php artisan cache:clear and php artisan config:cache

DB_CONNECTION=mysql
DB_HOST=localhost
DB_PORT=3306
DB_DATABASE=admin_clranke
DB_USERNAME=homeimpr_clranke
DB_PASSWORD=password
Knorr answered 27/2, 2022 at 21:14 Comment(0)
B
0

create and grant access to user homeimpr_clranke

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=admin_clranke
DB_USERNAME=homeimpr_clranke
DB_PASSWORD=password

make sure your database name is also correct and take note your cpanel username is attached to the db_database

Bitstock answered 8/3, 2021 at 21:43 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.