2

I just created a mysql docker container using

docker run -p 3310:3310 --restart always --env MYSQL_ROOT_HOST=% --name=ipca-mysql -e MYSQL_ROOT_PASSWORD=admin -d mysql/mysql-server:5.7

I am able to connect to my database using docker exec -ti ipca-mysql bash and mysql -u root -p

But when I tried to connect to my database at localhost:3310 using mysql workbench I get:

lost connection to mysql server at 'reading initial communication packet' system error 0

Any idea what is this issue?

Tiago
  • 69
  • 1
  • 7
  • The port number is normally 3306. If you run `netstat -pltn` in the container is it exposing at port 3306? – danblack Nov 03 '18 at 01:11
  • 1
    Possible duplicate of [docker mysql on different port](https://stackoverflow.com/questions/41637013/docker-mysql-on-different-port) – David Maze Nov 03 '18 at 07:47

2 Answers2

2

MySQL container start using this command it's worked.

docker run -p 3310:3306 --restart always --env MYSQL_ROOT_HOST=% --name=ipca-mysql -e MYSQL_ROOT_PASSWORD=admin -d mysql/mysql-server:5.7
Shahbaz A.
  • 4,047
  • 4
  • 34
  • 55
Mayur Kothari
  • 254
  • 2
  • 4
0

You could use this docker command:

docker run --name mysql-tacs -e MYSQL_ROOT_PASSWORD=root -d -p 3310:3306 mysql

In the link below there is a video which shows step by step the creation of mysql server with docker until the connection in its server using MySQL Workbench. https://www.youtube.com/watch?v=ZZwvhMvUJiw

lemon
  • 14,875
  • 6
  • 18
  • 38