How to connect database in laravel 5.8
Introduction
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_NAME=My_New_project_Name
APP_URL=http://localhost:8000/ #once hosted change to domain name
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
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