Hello everyone, please I got this error while trying to connect my docker container that is running in an AWS EC2 instance to MySQL workbench, "Failed to connect to mysql at 127.0.0.1:6666 with user root". The security group of my EC2 instance is set to access request from anywhere and the EC2 instance is running. I did a
docker ps
command which showed that my container is up and running. This is my docker run command:
docker run -d -p 6666:3306 --name=docker-mysql --env="MYSQL_ROOT_PASSWORD=root" --env="MYSQL_DATABASE=mydb" mysql
. While my docker container was running I tried to test my connection from MySQL workbench with Hostname on workbench as
127.0.0.1
and with port
6666
but the connection failed from workbench. This is the content of my dockerfile -
FROM centos
RUN cd /etc/yum.repos.d/
RUN sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-*
RUN sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' /etc/yum.repos.d/CentOS-*
RUN yum install -y httpd
ADD index.html /var/www/html
CMD apachectl -D FOREGROUND
EXPOSE 80
MAINTAINER babatunde
ENV myenv myval
ENV myenv2 myval2
I've also tried Hostname from workbench as
0.0.0.0
but I got the same error. I've also confirmed that no port is blocked by Firewall on my computer. Please does anyone knows how I can resolve this issue ? Thanks for any help in advance.
What I have tried:
docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
3071748c4ecd mysql "docker-entrypoint.s…" 37 minutes ago Up 37 minutes 33060/tcp, 0.0.0.0:6666->3306/tcp, :::6666->3306/tcp docker-mysql