Hello friends, this is a tutorial website. Today’s topic is that the database connection in laravel 8 is done by going to which file. So let’s try to understand.
When you install laravel 8, you will have to go to the .env file. After going there, you will have to provide the username of the database, the name of the database and the password there. You are told by the example below .env file can change.
.env file
APP_ENV=local
APP_DEBUG=true
APP_KEY=base64:Lrha/Q0oTFi09G0qm6HI4kqj9ekQB9sK5L4/8AgOop0=
APP_URL=http://localhost
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=db_name //database name here
DB_USERNAME=username //database username here
DB_PASSWORD=password //database password here
CACHE_DRIVER=file
SESSION_DRIVER=file
QUEUE_DRIVER=sync
REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379
MAIL_DRIVER=smtp
MAIL_HOST=mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
You are told above by way of example. You have to change in the env file but it has been darkened so that you can be explained in a very simple way.