OneBite.Dev - Coding blog in a bite size

Connect database on app and GUI for Laravel Sail

Using Laravel Sail? here is how you can connect to your mysql database to your app or GUI like tableplus

Using Laravel Sail? here is how you can connect to your mysql database to your app or GUI like tableplus

Connect your app

If you’re using MySQL, change DB_HOST in your .env file to mysql

..
DB_CONNECTION=mysql 
DB_HOST=mysql <- Look at that!
DB_PORT=3306
...

Reason
Since Sail using Docker, we need to match the image name we set for our database on docker-compose file

Connect GUI database like tableplus

Notes: for mysql 8, I think we must connect with 127.0.0.1 instead of localhost.

Warning

Make sure you don’t have other ‘mysql’ services running locally.

Mac user for example, can run this command to stop local mysql

brew services stop mysql
laravel