3

I created a new project and set up my database accordingly in the .env file.

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=8889
DB_DATABASE=example_olddb
DB_USERNAME=example_user
DB_PASSWORD=example_password

After much development, I want to change my database to a new database. So I edited the '.env' file again.

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=8889
DB_DATABASE=example_newdb///<-- change here
DB_USERNAME=example_user
DB_PASSWORD=example_password

However, I got the following error.

SQLSTATE[HY000] [1049] Unknown database 'example_olddb'

It used to work in Laravel 5.5 and 5.6, but not now in 5.7. I tried to clear the cache, but same error persists. How can I resolve this issue?

Karl Hill
  • 12,937
  • 5
  • 58
  • 95
sooon
  • 4,718
  • 8
  • 63
  • 116

1 Answers1

3

After completion of .env edit, You can clear the configuration cache with the following artisan command: php artisan config:cache

Udhav Sarvaiya
  • 9,380
  • 13
  • 53
  • 64