Connecting your laravel project to MySQL database is moderately easy. Since we have done the installation with XAMPP. It comes along with already installed MySQL and PHPMyAdmin. In this tutorial, I will make use of phpMyAdmin to create a new database that will connect to the laravel application. This post is assuming you already have a laravel project setup in your local and you are able to access its homepage via localhost or custom set domain name.
Step1: Create a new database via phpmyadmin
Navigate to domain name.dev/ PHPMyAdmin, Click on the Databases tab and create a new database with your wanted name.
Clicking on create will create a new database in your XAMPP MySQL.
Step2: Changes in.env configuration file
Once the database is created, you need to tell your laravel project the details about the database.
Laravel 5 has a pretty simple way to do that, All configuration that you should stay private and should not share goes into the .env file of your laravel project.
Modify the following property in your .env file according to your database settings.
Step3: Run migration (optional)
To test if you've got with success combined your Laravel project to the database you'll run the migration command. Laravel project by default comes with some default table for storing users and their password request. once you run migrate command you it ought to produce the default tables for you within the database.
php artisan migrate
That’s it! You are now ready to make database operations in your project.