[英]Connecting from Windows 7 to MySQL docker container on VirtualBox CentOs
I have Windows 7 on my laptop and used VirtualBox for install CentOs on it.我的笔记本电脑上装有 Windows 7,并使用 VirtualBox 在其上安装 CentO。 I have installed docker on CentOS and started MySQL server using:
我已经在 CentOS 上安装了 docker 并使用以下命令启动了 MySQL 服务器:
sudo docker run -name mysql -p 3306:3306
I can see that mysql container is up and running on VM but I am unable to connect to it from Windows using MySQL workbench.我可以看到 mysql 容器已启动并在 VM 上运行,但我无法使用 MySQL 工作台从 Windows 连接到它。 Is there a possibility to do so?
有没有可能这样做? edit: I have configured two adapters: first one is NAT and second one is a VirtualBox Host Only Network so I am able to connect to VB and have internet access.
编辑:我配置了两个适配器:第一个是 NAT,第二个是 VirtualBox Host Only Network,所以我能够连接到 VB 并可以访问互联网。 I am using 192.168.56.101 to connect to VB and it is successful.
我用192.168.56.101连接VB,成功了。 I can easily ping and connect to CentOS using ssh.
我可以使用 ssh 轻松 ping 并连接到 CentOS。 The issue is how to setup MySQL using docker so I will be able to connect to it from Windows?
问题是如何使用 docker 设置 MySQL 以便我能够从 Windows 连接到它? Should I use 127.0.0.0 and port 3306 or should I perform some routing or port forwarding?
我应该使用 127.0.0.0 和端口 3306 还是应该执行一些路由或端口转发?
I have resolved an issue.我已经解决了一个问题。 It seems like I could not connect because of MySQL changing their authentication style somewhere in releases 8.0
似乎我无法连接,因为 MySQL 在 8.0 版中的某处更改了身份验证样式
I have tried with an earlier version 5.7 as:我曾尝试使用早期版本 5.7 作为:
sudo docker run --name testdb-mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=admin -e MYSQL_DATABASE=testdb -d mysql:5.7
I have used 192.168.56.101:3306 address with root user and admin password in MySQL Workbench and it worked as intended.我在 MySQL Workbench 中使用了 192.168.56.101:3306 地址和 root 用户和管理员密码,它按预期工作。 No routing needed.
不需要路由。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.