Reputation: 352
Do i need to change database configuration in database.php file in laravel when upload to server?
'mysql' => [
'driver' => 'mysql',
'host' => env('DB_HOST', 'localhost'),
'port' => env('DB_PORT', '3306'),
'database' => env('DB_DATABASE', 'forge'),
'username' => env('DB_USERNAME', 'forge'),
'password' => env('DB_PASSWORD', ''),
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
'strict' => false,
'engine' => null,
],
Upvotes: 1
Views: 1874
Reputation: 163928
Don't change anything in database.php
config file. What you need to do is to change DB credentials in .env
file on server side.
So, you'll have different .env
files on a local machine and server, but the same database.php
config file.
https://laravel.com/docs/5.3/configuration#environment-configuration
Upvotes: 4
Reputation: 2736
Update your database.php
'mysql' => [
'driver' => 'mysql',
'host' => env('DB_HOST', 'localhost'),
'database' => env('DB_DATABASE', 'yourdatabasename'),
'username' => env('DB_USERNAME', 'root'),
'password' => env('DB_PASSWORD', 'password'),
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
'strict' => false,
],
Upvotes: 0