Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to connect to mysql running on docker using Sequel Pro

I have a docker-machine up and it has a mysql container running.

~
▶ boot2docker ip
192.168.59.103
~                                                                                                                                                                       
▶ docker-machine ip default
192.168.99.100

~
▶ docker-machine ls
NAME      ACTIVE   DRIVER       STATE     URL                         SWARM   DOCKER   ERRORS
default   *        virtualbox   Running   tcp://192.168.99.100:2376           v1.9.1

~
▶ docker ps
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                              NAMES
b14062dd1e25        mysql:5.6           "/entrypoint.sh mysql"   6 hours ago         Up 6 hours          3306/tcp, 0.0.0.0:3306->9090/tcp   i-mysql

logs from docker logs i-mysql

2016-01-20 04:14:41 1 [Note] InnoDB: Highest supported file format is Barracuda.
2016-01-20 04:14:41 1 [Note] InnoDB: 128 rollback segment(s) are active.
2016-01-20 04:14:41 1 [Note] InnoDB: Waiting for purge to start
2016-01-20 04:14:41 1 [Note] InnoDB: 5.6.28 started; log sequence number 1625997
2016-01-20 04:14:41 1 [Note] Server hostname (bind-address): '*'; port: 3306
2016-01-20 04:14:41 1 [Note] IPv6 is available.
2016-01-20 04:14:41 1 [Note]   - '::' resolves to '::';
2016-01-20 04:14:41 1 [Note] Server socket created on IP: '::'.
2016-01-20 04:14:41 1 [Warning] 'proxies_priv' entry '@ root@b14062dd1e25' ignored in --skip-name-resolve mode.
2016-01-20 04:14:41 1 [Note] Event Scheduler: Loaded 0 events
2016-01-20 04:14:41 1 [Note] mysqld: ready for connections.
Version: '5.6.28'  socket: '/var/run/mysqld/mysqld.sock'  port: 3306  MySQL Community Server (GPL)

How can I connect to the mysql instance in this container from my localhost laptop running OSX using Sequel Pro.

I'm using the below settings but I can't seem to connect:

enter image description here

Unable to connect to host 192.168.99.100, or the request timed out.

Be sure that the address is correct and that you have the necessary privileges, or try increasing the connection timeout (currently 10 seconds).

MySQL said: Can't connect to MySQL server on '192.168.99.100' (61)

like image 954
Anthony Avatar asked Jan 20 '16 10:01

Anthony


People also ask

How do I connect to my local Docker database?

A simple solution to this in a Linux machine is to use the --network=”host” option along with the Docker run command. After that, the localhost (127.0. 0.1) in your Docker container will point to the host Linux machine. This runs a Docker container with the settings of the network set to host.


1 Answers

You are exposing container port 9090 to host port 3306. Maybe you wanted the other way around. When you start the container please change -p flag parameter from 9090:3306 to 3306:9090

like image 73
OttavioMonzione Avatar answered Oct 04 '22 15:10

OttavioMonzione