When a Laravel app starts, it first reads the .env file to get database settings like connection type, host, port, database name, username, and password. These values are loaded step-by-step from the .env file. Then Laravel loads the config/database.php file, which uses these environment values to prepare the database connection configuration. After setting these parameters, Laravel attempts to establish a connection to the database server using the specified driver (like MySQL). Once connected, the app can run queries on the database. This process keeps sensitive info out of code and allows easy changes by editing the .env file. If any setting is wrong, the connection will fail, stopping database access.