Database Configuration and Migration in Laravel 9

Database Configuration and Migration

1. Open xampp and start Apache, MySQL.

2. Open phpmyadmin -> localhost/phpmyadmin/ and give the database name.

After that give the same database name in env file as mention below.

3. Open env file in laravel and set database name -

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=wscube
DB_USERNAME=root
DB_PASSWORD=

4. Run the first migration. what is migration? migration is a feature which is given by laravel. You do not need to go in database. You can directly manipulate database from the laravel. You can create tables, add columns, delete columns and much more using migration in the laravel.

5. Go to database>migrations> there by default created database tables from laravel.

6. Now open new terminal in visual studio code and run this command -

php artisan config:Cache
 When env file changes reconfigure this file again with this command.

7. Now run -


php artisan migrate
 to migrate tables. Before running this command please check xampp (Apache and MySQL). After migration all the tables will be add in the database. Now go to phpmyadmin and check if tables added or not.

Comments