I have a docker mysql image running, following is what the docker-compose.yml file looks like:
db:
image: mysql
environment:
MYSQL_ROOT_PASSWORD: \"\
If your Docker MySQL host is running correctly you can connect to it from local machine, but you should specify host, port and protocol like this:
mysql -h localhost -P 3306 --protocol=tcp -u root
Because you are running MySQL inside Docker container, socket is not available and you need to connect through TCP. Setting "--protocol" in the mysql command will change that.