Skip to content
Advertisement

How to connect my host mysql in docker container?

my.cnf configured = bind-address = 172.18.0.3(Docker Container ID) and bind-address = 0.0.0.0 in my host. I try connecting from docker container.

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=default
DB_USERNAME=root
DB_PASSWORD=root

But not connecting local mysql.I get this error

SQLSTATE[HY000] [2002] Connection refused

Advertisement

Answer

If you want to connect to your local database , you call give host.docker.internal in the place where we provide database url . Then give the db you want to specify along with db username and db password.

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement