简体   繁体   中英

Laravel 5.6 cannot connect to database after clearing cache

i cannot connect to database after clearing even php artisan is not working. here is how i clear config caches:

php artisan cache:clear

then it's cleared successfully but when i run:

php artisan config:cache

i got this error:

<pre><strong>ERROR:</strong> Can't connect to the database server. SQLSTATE[HY000] [1045] Access denied for user ''@'localhost' (using password: NO)</pre>% 

i also tried: composer dump-autoload but still no luck. Once in the past i got same error and i was able to solve it but no idea how. If someone knows solution then kindly explain it as well.

My php version: PHP 7.2.5-1+ubuntu18.04.1+deb.sury.org+1 (cli) (built: May 5 2018 05:00:15) ( NTS )

Thank you!

您用于连接数据库的用户没有连接权限,请提供对该数据库用户的访问权限

I don't know if i'm allowed to answer my own question or not. Let me know if it's not allowed to answer to your question.

In bootstrap directory which is located in root of your app. There i saw cache directory and then i just delete it and run:

composer dump-autoload

then it's works. But even if i try to run:

php artisan config:cache

it gonna be successful. But if after this you may get same error again:

php artisan serve       
ERROR: Can't connect to the database server. SQLSTATE[HY000] [1045] Access denied for user ''@'localhost' (using password: NO)

After this i try to delete config.php inside bootstrap/cache/ . it gonna work even after deleting that file.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM