Home > Enterprise >  How to connect to Docker DB (Laravel with ddev and MySQL)
How to connect to Docker DB (Laravel with ddev and MySQL)

Time:06-17

I have a Laravel project where I have to connect to a MySQL db. I deployed the project with ddev, so I´m using docker. The .env file have this credentials:

DB_CONNECTION=mysql
DB_HOST=db
DB_PORT=3306
DB_DATABASE=db
DB_USERNAME=db
DB_PASSWORD=db

With this configuration, I can do migrations, and all goes in the right way, but HOW can I see this database? Can I link a DB which is in my local MySQL server? For example, Can I change this host for localhost and set a DB created by me?

I really don´t know why this works, so if somebody helps me, I will be thankfull.

CodePudding user response:

You can explore your database in so many different ways:

  • ddev mysql
  • ddev launch -p (or click the link in ddev describe to use PhpMyAdmin
  • Use the mysql client in either web container or db container

You can export the database to text format with ddev export-db or make a binary snapshot with ddev snapshot.

There's lots more detail and more options for database browsers at https://ddev.readthedocs.io/en/latest/users/topics/database_management/

  • Related