1 | initial version |
To establish a connection to MySQL in Laravel/Sail while operating in WSL2, you need to follow these steps:
First, make sure that you have Docker Desktop installed and running on your Windows machine.
Open up your WSL2 terminal and navigate to your Laravel project directory.
Next, run the following command to install Laravel Sail:
composer require laravel/sail --dev
./vendor/bin/sail up
./vendor/bin/sail mysql
Note: Make sure to update your database configuration in the .env file to connect to the database using the following credentials:
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=laravel
DB_USERNAME=sail
DB_PASSWORD=password