Unable to connect Sequel Pro with mysql docker container - mysql

I feel like this should be an easy fix but I can't seem to figure this out. I just installed docker and ran:
docker run -d --name test-mysql -p 3306:3306 -e MYSQL_ALLOW_EMPTY_PASSWORD=yes -e MYSQL_DATABASE=test mysql
I did this to create my first container. After that I opened sequel pro an typed in the correct things to connect to the database. I got this...
Unable to connect to host 127.0.0.1, 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: Host '172.17.0.1' is not allowed to connect to this MySQL server
Does anyone know how to fix this?

Related

Docker access to GCP SQL proxy

I'm facing a issue and I will appreciate you someone can help me.
I cannot connect to mysql proxy from my docker container.
GCP Enviroment
I have a GCP VM unix with docker installed.
This VM has already the Google Could Sql Proxy configured, and accessible through mysql -u USER -p --host=127.0.0.1 --port=5435
I have a docker container with Ubuntu
Problem
The problem is, inside my container, if I run mysql -u USER -p --host=host.docker.internal --port=5435 or mysql -u USER -p --host=172.17.0.1 --port=5435 I connect access
I cannot connect to mysql. I don't know what I'm missing or doing wrongly.
Thank you!

MySql Docker container refuses to connect to Microsoft Azure (Mac)

First of all - hello. Secondly, I just downloaded Docker and got it to run MySql on my Mac. It has never connected before and I am trying to learn how to make databases.
Everything was running smoothly - I opened Docker and ran my container (it is running), but when I tried to connect with Microsoft Azure, it persistently refused to do so.
Since my password was strong enough to fill the criteria, I checked the port and it is indeed 1433.
So I started to use every variation I could think of in username, just to see what happens.
Nothing. No connection. I read it could be the firewall, but all the instructions I found were Windows and other applications.
Can anyone here point me in the right direction? It seems such a pathetic hill to die on.
docker run --name <your-mysql-name> -e MYSQL_ROOT_PASSWORD=<your-sql-password> -p <host-port>:<container-port> -d mysql
You'll need to expose / publish the port (-p command), if not MySQL cannot be accessed by external sources.
For example:
docker run --name test-mysql -e MYSQL_ROOT_PASSWORD=somepassword -p 3306:3306 -d mysql
The user name is "sa". I found it on a blog and tried it out. It worked.

Docker Can't connect to MySql server on 0.0.0.0 (10049)

Using latest Docker desktop and mariadb/latest image I have created a container, which runs OK, local MySQL command work successfully.
BUT whatever I try to connect to the container with HeidiSQL, I get
"Can't connect to MySql server on 0.0.0.0 (10049)"
I think I have read at least 50 different "solutions" here and on other sites, but whatever I do, I get the same error, whatever IP I use.
Running Windows 10 Pro freshly updated, as with latest Docker desktop.
Created the container with
docker run -p 3306:3306 --name demo -e MYSQL_ROOT_PASSWORD=xyz -d mariadb/server --log-bin --binlog-format=MIXED
Changed binding in my.cnf to 0.0.0.0
Granted all rights to 'root'#'%' thru local mysql cli.
Restarted the whole shebang NUMEROUS times
Tried connections on 0.0.0.0, 127.0.0.1, localhost, 172.17.0.2, etc, etc, etc.
"docker ps" says PORT: "3306/tcp"
Using bash in the container, I can reach out and apt update etc, etc.
I'm out of options. Is there a kind guru out there with a new suggestion?

Connect to mysql in a Docker container from another Docker container in a MacOS host

I have been trying to set up several Docker containers for different mysql databases in my MacOS host system.
So, I have 2 different mysql databases in containers built from the mysql/mysql-server:5.7 image.
docker run --name=db-1 -d -p 1200:3306 mysql/mysql-server:5.7
docker run --name=db-2 -d -p 1201:3306 mysql/mysql-server:5.7
Since they are binded to 0.0.0.0:120x, I am able to access the mysql cli using
mysql -uroot -p -h 0.0.0.0 -P 120x (WORKS)
However, I really wanted to try and access the databases using the IP of the container which I found using
docker inspect db-1 | grep IPAddress
I found that the IP of the container is 172.17.0.8
So logically
mysql -uroot -p -h 172.17.0.8 -P 3306
should have worked, but it doesn't.
I get an error that reads out ERROR 2003 (HY000): Can't connect to MySQL server on '172.17.0.8' (60)
I was trying to access using the container IP so I could access the databases from other containers by linking them. However this doesn't seem to work.
What am I missing?

Cannot connect to MySQL server inside Docker

First I run mysql image:
docker run -e MYSQL_ROOT_PASSWORD=password -d -p 127.0.0.1:3308:3306 mysql
Then I use container bash:
docker exec -it my_container_name bash
In Bash I can successfully connect to MySQL server via command:
mysql -uroot -ppassword
But when I try to connect to MySQL container from Windows cmd:
mysql -uroot -ppassword -h127.0.0.1 -P3308
ERROR 2003 (HY000): Can't connect to MySQL server on '127.0.0.1' (10061)
If I connect to 192.168.99.100 instead (this ip is returned by docker-machine ip), then the result is the same.
The question is: How do I correctly expose my MySQL port inside Docker to outside Windows?
The error is in your port mapping in the original docker run command, you just need to provide the ports, not the IP address:
docker run -e MYSQL_ROOT_PASSWORD=password -d -p 3308:3306 mysql
You can run docker ps -a to check for the port mapping in the running containers.
You should now be able to connect to MySQL using
mysql -uroot -ppassword -h192.168.99.100 -P3308
First, check netstat -an to make sure the port is open in Windows. If it is, also check the Windows firewall to make sure nothing is blocking connections to the port.
Most of my Docker experience is in CoreOS, so I'm not exactly sure how Windows handles routing traffic into the container. In CoreOS, it uses a proxy. If there is a proxy in Windows, make sure nothing is interfering with it.
Changing the port in which I was running the image worked.
I checked if this port was used by something else, but it was not used. so I just -desperately- run a new container in a different port '3309'. and it worked fine!
Make sure you have entered the port with -P.