If you’re trying to connect from outside of Docker, your docker run -p
option is wrong: the second port number always needs to be the standard port number of its service. For MySQL, that second port number needs to be 3306, always. The two port numbers need to match.
docker run -d -p 3307:3306 ... mysql
# ^^^^
# must be the standard port number
ANOTHER OPTIONS
// first of all disable mySql Service if it was installed before or you will receive error like this
Lost connection to MySQL server at 'reading initial communication packet', system error: 0
// start docker container on 3307 port
docker run --name mysqlContainer -p 3307:3307 -e MYSQL_ROOT_PASSWORD=root -e MYSQL_ROOT_HOST=% -d mysql:latest
// connect to mysql monitor
mysql -h localhost -P 3307 -u root -proot
// bash inside docker
docker exec -it mysql bash