How to connect database in laravel 5.8


All of the configuration files for the Laravel framework are stored in the config directory. But, we will directly access Environment Configuration file i.e dot env (.env) file.

So in your .env file you will access many things like App_name, App_urls, database configuration, 

APP_URL=http://localhost:8000/ #once hosted change to domain name

DB_DATABASE=your_database #do not use this symbol Hash (#) in database
DB_USERNAME=your_username #do not use this symbol Hash (#) in username
DB_PASSWORD=your_password #do not use this symbol Hash (#) in password

Now , your .env file is setup and ready to start the project but before that make sure you have created a database in server, example in XAMPP, WAMPP or LAMP.

So, you are Successfully Configured with your database and start to serve your artisan. 

Note: If you do any changes in .env file, restart or re-serve your artisan by using below command:

$ php artisan serve