Reputation: 143
I am new to Laravel(ver 5.5). This is config/database.php file:
'mysql' => [
'driver' => 'mysql',
'host' => env('DB_HOST', '127.0.0.1'),
'port' => env('DB_PORT', '3306'),
'database' => env('DB_DATABASE', 'mfa'),
'username' => env('DB_USERNAME', 'root'),
'password' => env('DB_PASSWORD', 'mypass'),
'unix_socket' => env('DB_SOCKET', ''),
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
'strict' => true,
'engine' => null,
],
And here is my route on routes/web.php:
Route::get('/', function ()
{
Schema::create('books',function($newtable){
$newtable->increments('id');
$newtable->string('writer');
$newtable->string('title',500);
$newtable->text('description');
$newtable->date('published');
$newtable->integer('copies');
$newtable->timestamps();
});
return view('welcome');
});
The database exists and called 'mfa', the username is 'root'. It seems it is trying to log in as 'homestead' despite it is 'root'. This is an error code: SQLSTATE[HY000] [1045]
Upvotes: 1
Views: 1142
Reputation: 403
Run This Command First to clear Cached: php artisan config:clear
.env File:
APP_NAME=Laravel
APP_ENV=local
APP_KEY=base64:Pf8bqFhStKix4rtdt1FOgvPpudMqsYyw+Uv+dOvaF8w=
APP_DEBUG=true
APP_LOG_LEVEL=debug
APP_URL=http://localhost
DB_CONNECTION=mysql
DB_HOST=localhost
DB_PORT=3306
DB_DATABASE=mfa
DB_USERNAME=root
DB_PASSWORD=mypass
BROADCAST_DRIVER=log
CACHE_DRIVER=file
SESSION_DRIVER=file
QUEUE_DRIVER=sync
REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379
MAIL_DRIVER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
PUSHER_APP_ID=
PUSHER_APP_KEY=
PUSHER_APP_SECRET=
'mysql' => [
'driver' => 'mysql',
'port' => env('DB_PORT', '3306'),
'host' => env('DB_HOST', 'localhost'), //127.0.0.1
'database' => env('DB_DATABASE', 'mfa'),
'username' => env('DB_USERNAME', 'root'),
'password' => env('DB_PASSWORD', 'smus82'),
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
'strict' => false,
],
NOTE: You need to Restart The Server After Changing in
.env
file. to apply the settings.
Upvotes: 1
Reputation: 143
APP_NAME=Laravel
APP_ENV=local
APP_KEY=base64:Pf8bqFhStKix4rtdt1FOgvPpudMqsYyw+Uv+dOvaF8w=
APP_DEBUG=true
APP_LOG_LEVEL=debug
APP_URL=http://localhost
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=mfa
DB_USERNAME=root
DB_PASSWORD=mypass
BROADCAST_DRIVER=log
CACHE_DRIVER=file
SESSION_DRIVER=file
QUEUE_DRIVER=sync
REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379
MAIL_DRIVER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
PUSHER_APP_ID=
PUSHER_APP_KEY=
PUSHER_APP_SECRET=
Upvotes: 0