Clear Laravel cache(s) without Artisan command

15,496

Solution 1

Not sure you have solved this, my suggestion is remove the files inside below folder. So the database connection cache file will create again after removed. (Laravel 5)

/<root>/bootstrap/cache/*

Hope it helps :)

Solution 2

You can call an Artisan command outside the CLI.

Route::get('/clear-cache', function() {
   $exitCode = Artisan::call('cache:clear');
   // return what you want
});

You can check the official doc here http://laravel.com/docs/5.0/artisan#calling-commands-outside-of-cli

Solution 3

If someone still has such problem, check out your password for database. It seems like .env file does not accept # sign, that's why I had the same error.

Solution 4

It's one time only? Just delete the folder storage/framework/cache/data

Share:
15,496
Matthew
Author by

Matthew

Almost always playing around in the depths of archives, thumbing through one document at a time and the rest of the time, building drupal sites. :)

Updated on June 06, 2022

Comments

  • Matthew
    Matthew almost 2 years

    I've moved my project but have run into an issue. I'm discovering that the old settings (which have been changed in my .env to reflect the changed host) are still being used by my project.

    I can't access my project through a browser as it returns this error: SQLSTATE[HY000] [1045] Access denied for user 'appReop'@'localhost' (using password: YES) (SQL: select * from `settings` limit 1)

    appReop was the previous login username. And while I could just create a new user to reflect this, I also run into an issue about the old password being too weak for the current database configuration.

    When I go to run php artisan cache:clear, it returns the same above error. So I was curious if there was a way to manually clear the caches to fix my errors?

    Update

    This shows the three errors that pop up after running any Artisan command:

    enter image description here

  • Matthew
    Matthew over 5 years
    Yes, it is one time only. And unfortunately, I deleted the folder prior to this and nothing had happened.
  • Felippe Duarte
    Felippe Duarte over 5 years
    Seems this is not a cache issue, but configuration. Look for credentials at config/database.php
  • Matthew
    Matthew over 5 years
    I've changed those too in the hopes that it was that. But after changing everything it is still somehow relying on caching somewhere as it still tries to connect using the old credentials.
  • Matthew
    Matthew over 5 years
    I've tried that but it continues to give the error. I've tried all of the artisan commands at this point to do with caching.
  • Matthew
    Matthew over 5 years
    And I should clarify that it is giving me the error in the console as well, not just the web browser
  • Matthew
    Matthew over 5 years
    I've updated my question with a screenshot, but at this moment, no artisan commands work. That's why I'm hoping to try and locate the issue either in caches or code... :/
  • Josh
    Josh over 5 years
    Try creating a file called down in storage\framework this should put Laravel into maintenance mode manually.
  • N. Djokic
    N. Djokic about 4 years
    It helped a lot. Thanks.
  • Kyle Reierson
    Kyle Reierson over 3 years
    This saved me, thanks!
  • Dany Balian
    Dany Balian about 3 years
    upvote just for thinking outside of the box!