7

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

halfer
  • 19,824
  • 17
  • 99
  • 186
Matthew
  • 1,565
  • 6
  • 32
  • 56
  • As [Andrey Mikhalev](https://stackoverflow.com/users/7228796/andrey-mikhalev) says, try wrapping your password with single quotes. I hope this help someone. – Alk May 06 '20 at 23:05

6 Answers6

16

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 :)

Jimmy
  • 161
  • 1
  • 3
7

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

MD. Jubair Mizan
  • 1,539
  • 1
  • 12
  • 20
1

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

Felippe Duarte
  • 14,901
  • 2
  • 25
  • 29
  • Yes, it is one time only. And unfortunately, I deleted the folder prior to this and nothing had happened. – Matthew Nov 29 '18 at 18:19
  • Seems this is not a cache issue, but configuration. Look for credentials at `config/database.php` – Felippe Duarte Nov 29 '18 at 18:29
  • 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 Nov 29 '18 at 18:35
  • 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 Nov 29 '18 at 19:35
  • And I should clarify that it is giving me the error in the console as well, not just the web browser – Matthew Nov 29 '18 at 19:36
1

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.

0

Try running:

php artisan down
php artisan config:clear

As this will place Laravel in maintenance mode and then clear only the config setting cache.

@Filippe commented about this already.

Update

Just create a file called down like in the picture below then run php artisan config:clear and then if it works php artisan up.

enter image description here

halfer
  • 19,824
  • 17
  • 99
  • 186
Josh
  • 1,316
  • 10
  • 26
  • 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... :/ – Matthew Nov 29 '18 at 21:42
  • Try creating a file called down in `storage\framework` this should put Laravel into maintenance mode manually. – Josh Nov 29 '18 at 22:14
0

rather batter if you could provide permission to your storage directory.

$ sudo chmod -R 777 ./storage

then remove cache and using php artisan cache:clear.I hope this will help you.

Manish J
  • 686
  • 1
  • 8
  • 24