How to connect laravel 5.x to database

Find the .env file in your project directory and edit it with editor, Some times it will not visible on file explorer because it has '.' in front of file.

 

Laravel

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306  // database running port
DB_DATABASE=blog  // your database name
DB_USERNAME=root  // your database username
DB_PASSWORD=      // your database password

and save it now you should have connected successfully your laravel project to database

Other posts