Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Spiral's avatar

SQLSTATE[HY000] [1044] Access denied for user ''@'localhost' to database 'forge' (SQL: select `active_template` from `general_settings` limit 1)

I have cloned a project after that not working run any command giving same error on every command..

0 likes
16 replies
tisuchi's avatar

@spiral In your .env file, you have to set the proper database value.

e.g.

DB_CONNECTION=mysql
DB_HOST=db
DB_PORT=3306
DB_DATABASE=laravel
DB_USERNAME=laravel
DB_PASSWORD=laravel

Here, you need to set your proper values.

1 like
Spiral's avatar

Thanks, Dear @tisuchi for replying to me...

I have set proper but can not understand why it's coming

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=qr
DB_USERNAME=root
DB_PASSWORD=
tisuchi's avatar

@spiral Your error is saying that you are trying to connect with forge not in qr.

'@'localhost' to database 'forge'

Make sure that.

1 like
Spiral's avatar

Dear, how can I make sure that.. because I'm giving qr database in .env

tisuchi's avatar

@spiral If you are sure that you put the correct values in the .env file already, then try these commands and run-

php artisan cache:clear 
php artisan config:cache

Then run your application again.

1 like
Spiral's avatar

Dear not running any command... My mean that

php artisan 

not working on every command giving same problem

tisuchi's avatar

@spiral after cloning the project, did you run the following command in the root directory of your project?

composer install
1 like
Spiral's avatar

Yes Dear but not working any command due to this problem

Snapey's avatar

delete the file bootstrap/cache/config.php

You cannot run these commands because there is something trying to access the database in one of the service providers of the constructor of a console command

1 like
Spiral's avatar

Thanks, @snapey for replying to me.

I have not config.php file in bootstrap/cache

I have bought this script from Envato platform but not running in local giving these issues

Snapey's avatar

Check the config/database.php file.

What does the mysql section look like?

siangboon's avatar

try to disable all the execution in the AppServiceProvider first for temporary

ferdian's avatar

i had the same problem, SQLSTATE[HY000] [1045] Access denied for user 'u1665224_ferdian1'@'localhost' (using password: YES) (SQL: select active_template from general_settings limit 1) is there any other way without clear cache

jackbaron's avatar

i have a same problem. but i not found a solution for this. i think problem in the AppServiceProvider. i had a query i used in the boot function. I think this was trying to executed before env file loaded. any solution for help me?

Please or to participate in this conversation.