1.宿主机无法连接docker里的mysql
报错如下:
[root@localhost ~]# mysql -h 127.0.0.1 -uroot -p -A
Enter password:
ERROR 2013 (HY000): Lost connection to MySQL server at 'reading initial communication packet', system error: 0
如果是localhost。则报错如下:
[root@localhost ~]# mysql -P 3306 -uroot -p -A
Enter password:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
First of all, you need to figure out what your port 3306 is listening to?
If you have not started mysql on the host machine on 3306, you can use it when starting the mysql program in docker
Map docker’s 3306 port to the host’s 3306 port.
This way you can use it on the host machine
Connect to mysql in docker.