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

gitwithravish's avatar

Base table or view does not exist

  • I cloned a project from github
  • I changed the database credentials from remote to local in .env
  • Everything works fine.
  • But then I changed the env variables again and try to config cache but got this error
Base table of view does not exist...

I tried to run the following commands

php artisan cache:clear
php artisan config:cache

But still instead of rewriting the cache, artisan was throwing the same error. It is trying to make db request by using old env variables. How do I fix this?

0 likes
11 replies
gitwithravish's avatar

well the problem with the migrations is that they are not maintained by the original developers. So the database is cloned directly from server to localhost @marianomoreyra

Tray2's avatar

The error message tells you that it can't find the table or view. Make sure all database items are present and you should be good.

gitwithravish's avatar

As I have mentioned, the issue is it is trying to access oldBD.table, but I do not have that db in my server. I have my target database with other name and it has everything that is needed. I am trying to clear the cache so that the app can connect to the database of which credentials I have added in the env. @tray2

Tray2's avatar

What happens if you run this in a terminal?

  • php artisan tinker
  • <your model>::all();

Does it give the same error or does it return a list of records from <your model>?

neilstee's avatar
neilstee
Best Answer
Level 34

@gitwithravish looks like you can't cache because it's checking the old config, what you can do is delete the bootstrap/cache/config.php file manually.

gitwithravish's avatar

Well yeah I did that only and it worked. But I put put out this question to understand why it happened.

1 like
neilstee's avatar

@gitwithravish I think what happens is when you run php artisan config:clear it looks in the bootstrap/cache/config.php file if what cache driver you are using (file, redis, database) so it can delete the cache.

The problem is, looks like your old config is set to database, and looking for cache table which doesn't exist giving you base table error. Not 100% sure about this but that's what I thought when I suggest deleting the config file manually.

Glad it works tho!

munazzil's avatar

use below steps,

          php artisan cache:clear
          php artisan config:clear
          php artisan view:clear

and then run,

         composer  dump-autoload

and make sure to hard refresh ctrl+f5 otherwise effect not take place.

Please or to participate in this conversation.