How can I connect to MySQL inside my docker container that is hosted locally on my mac? I'm trying to connect via SequelPro and can't even get test connection to work.
Here's my Docker command:
docker run -it --name rodneys_mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=password -e MYSQL_DATABASE=demo mysql
I can connect via command line:
docker exec -it rodneys_mysql mysql -uroot -p
I know how to get the ip address of the docker container:
docker inspect <container id> | grep "IPAddress"
But I can't connect via SequelPro from my host machine.
Solved by using 127.0.0.1 instead of localhost, because localhost would mean docker container itself. Also don't forget to grant user a privilege to connect:
grant all privileges on *.* to 'root'@'172.17.0.1' identified by 'password';
Or for all hosts:
grant all privileges on *.* to 'root'@'%' identified by 'password';
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With