简体   繁体   English

Laravel 5.6清除缓存后无法连接到数据库

[英]Laravel 5.6 cannot connect to database after clearing cache

i cannot connect to database after clearing even php artisan is not working. 清除php artisan后,我无法连接到数据库。 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. 我也尝试过: composer dump-autoload但仍然没有运气。 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 ) 我的PHP版本: 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. 在应用程序目录中的bootstrap目录中。 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/ . 之后,我尝试删除bootstrap / cache /中的 config.php it gonna work even after deleting that file. 即使删除该文件,它仍然可以工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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