I try connect my mysql host DB from docker container by using host mode and I get the error:
docker run --rm -it --network=host mysql mysql -h 127.0.0.1 -utestuser -p
ERROR 2003 (HY000): Can't connect to MySQL server on '127.0.0.1:3306' (111)
The base of my work is stackoverflow-answer https://stackoverflow.com/a/24326540/1514029
My host mysql version is 8.0.25.
I tried in my.cnf bind-address = 0.0.0.0 and bind-address = 172.17.42.1
Every binding have the same problem.
I grant the testuser user access to 127.0.0.1 by statements
CREATE USER testuser@127.0.0.1 IDENTIFIED BY 'blah'
grant all privileges on *.* to testuser@127.0.0.1 with grant option
On docker bridge mode my connection work fine only on docker host mode it fails!
It must be a network problem??
you can use:
docker run --name mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=123456 -d mysql:8.0.25
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.