refactorian / laravel-docker

Laravel Docker Template - Laravel v11.x, PHP v8.3.x, MySQL v8.1.x, phpMyAdmin v5.x, Mailpit v1.x
286 stars 117 forks source link

DB-Host problem. #53

Closed Skaywalker closed 7 months ago

Skaywalker commented 7 months ago

Sorry, I still have a little problem. When I migrate the database, I find that the migration is running. But the page is connected to the database. image image but if I replace DB-HOST with db, the page runs. But then I can't use the database from my terminal. I have already added the network settings so that docker can work as a bridge.

Thank you in advance for your help.

refactorian commented 7 months ago

@Skaywalker Yes, you've to set the DB_HOST to db. It's written in the .env.example https://github.com/refactorian/laravel-docker/blob/95797abd4fcce23407436199c58389c07cfa8a5b/.env.example#L22-L27

MySQL is in the db container. Run docker compose exec db bash to access it. Once you're inside the container you can access MySQL from there.

mysql -urefactorian -p Enter password: (refactorian) mysql> SHOW DATABASES;