Here is a simple guide on establishing a connection between your database(MySQL) and Laravel application.
This can be done either by a database manager eg phpMyAdmin or the Command Line Interface (CLI).
Command Line Interface(CLI)
A database can be created with the following command:
CREATE DATABASE db_name;
P.S: You have to log in to MySQL before you can create a database via any of these methods.
Laravel default environment file
.env contain some common configuration values that differ based on if your application runs locally or on a production server.
P.S: This configuration values are based on my local machine ,
yours may differ, do well to confirm.
.env with the database name you want to connect to,as well as the other environment variables if they differ from the default.
DB_CONNECTION=mysql DB_HOST=127.0.0.1 DB_PORT=3306 DB_DATABASE=test DB_USERNAME=root DB_PASSWORD=
Hurray! 🎉The laravel application is now properly connected to the database.
Laravel migrations simply allows you to easily perform certain actions to the database without going to the database manager (eg. phpMyAdmin). They can also serve as a version control for your database. They create tables, columns as well as modify them etc.
It can be executed to the database with the following command:
php artisan migrate
P.S : Refresh your database , it has been updated with users' table and its properties.
You're all set to continue building!😎
Thank you for reading🤝