3

Edit: php artisan config:cache work nice, but now I got other problem. the URL giving me Error 500

I upload a project to a new subdomain area after I changed .env file when I open URL I still got an error with the old database and user

error screen shoot

I tried to check online with the .env file but - I don't know where he stored this database, I tried to see where is this name with ctrl+f but - nothing found

DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=faceterc_hot
DB_USERNAME=faceterc_hot
DB_PASSWORD=testpro

I expect to get the same error maybe but not with the old database name. and this gives me a indicate that maybe the file or something not changed or he using the other details from I don't know where

Elroy Cohen
  • 41
  • 1
  • 4

6 Answers6

4

Good, practice for, If you change in a .env file first restart the server using below command.

php artisan serve

then after run below more command for clear old cache and config.

composer dump-autoload
php artisan config:cache
php artisan config:clear
Sujal Patel
  • 2,444
  • 1
  • 19
  • 38
1

You can simply do a

php artisan config:cache

In case you are on a shared hosting, you can change the values in config/database.php to only use the set values in your .env. Setting it like this will make sure, it only use the .env values.

mysql' => [
'driver'    => 'mysql',
'host'      => env('DB_HOST'),
'database'  => env('DB_DATABASE'),
'username'  => env('DB_USERNAME'),
'password'  => env('DB_PASSWORD'),
'charset'   => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix'    => '',
'strict'    => false, 
],
Aditya Thakur
  • 2,562
  • 2
  • 10
  • 21
1

php artisan config:clear Solve the problem with DATABASE error just ran : php artisan config:clear with ssh at the main folder.

Elroy Cohen
  • 41
  • 1
  • 4
0

Just execute

php artisan config:cache

as the laravel cache's the environment files rather than accessing the data from it on every request.

oreopot
  • 3,392
  • 2
  • 19
  • 28
  • its work i think. but now i got error 500 - The server encountered an internal error or misconfiguration and was unable to complete your request. – Elroy Cohen May 15 '19 at 10:49
0

It's always a good practice to run these couple of commands when you change any environment related variable:

php artisan config:clear
php artisan cache:clear
Deepak Singh
  • 610
  • 1
  • 7
  • 23
-1

Execute these commands:

php artisan config:cache
php artisan route:cache
php artisan optimize

That will clear your env cache and it should do.

César Escudero
  • 320
  • 2
  • 12