0

I'm trying to connect to mysql on Docker. I used ./vendor/bin/sail up to start Laravel.

The command docker container ls returns the followings:

ID  88df79d8937f
IMAGE   mysql:8.0
COMMAND "docker-entrypoint.s…"
CREATED 38 minutes ago
STATUS  Up 38 minutes (healthy)
PORTS   0.0.0.0:3306->3306/tcp, 33060/tcp
NAMES   laravel-app_mysql_1

I used docker container inspect to find IPAddress:

❯ docker container inspect 88df79d8937f | grep "IPAddress"
            "SecondaryIPAddresses": null,
            "IPAddress": "",
                    "IPAddress": "172.24.0.4",

In Sequel Pro, I use 172.24.0.4 for Host, sail for username, password for Password.

I get an error telling "Unable to connect to host 172.24.0.4, or the request timed out."

How can I use SequelPro or another DB client to connect to Docker MySQL?

enter image description here

shin
  • 31,901
  • 69
  • 184
  • 271

1 Answers1

0

You should just put in localhost as the host, as it is exposed this way on the host.

Host: 127.0.0.1 or localhost

Username: what you put in your .env under DB_USERNAME

Password: what you put in your .env under DB_PASSWORD

Bonus (relevant but not needed for this problem):

172.24.0.4 is for container to container communication. Which can change every restart of your containers so it's better not to use their ip's but reference each other using their container name.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
online Thomas
  • 8,864
  • 6
  • 44
  • 85