启动在VMware中的Docker中的mysql

本文档指导如何在VMware环境下操作,启动CentOS上的Kuber OS,然后连接并管理运行在Docker容器内的MySQL服务。步骤包括检查iptables,启动和管理MySQL容器,确保防火墙政策允许连接,并从本地PC通过MySQL工具连接到数据库。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1. start VMware, then startup the centos kuber OS

2. use ssh tool connect to centos kuber os as root, and check iptables port, restart iptables if needed

iptables -L -n
v:显示详细信息,包括每条规则的匹配包数量和匹配字节数
x:在 v 的基础上,禁止自动单位换算(K、M)
n:只显示IP地址和端口号,不将ip解析为域名
  systemctl start iptables.service
  systemctl status iptables.service
  systemctl stop iptables.service

3. check and start mysql container

[root@localhost ~]# docker ps
CONTAINER ID        IMAGE                 COMMAND                  CREATED             STATUS              PORTS                                              NAMES
e39d8a6d7ec1        docker.io/mysql:5.7   "docker-entrypoint..."   10 days ago         Up 22 minutes       0.0.0.0:3307->3306/tcp, 0.0.0.0:32768->33060/tcp   sad_einstein
[root@localhost ~]# docker start e39d8a6d7ec1

4. once mysql container startup, login to Docker mysql image from centos kuber OS(local pc)

[root@localhost ~]# docker exec -it sad_einstein bash
root@e39d8a6d7ec1:/#

5. check and start mysql 

[root@localhost ~]# docker exec -it sad_einstein bash
root@e39d8a6d7ec1:/# service mysql status
[info] MySQL Community Server 5.7.29 is not running.


root@e39d8a6d7ec1:/# service mysql start
...
[info] MySQL Community Server 5.7.29 is started.


root@e39d8a6d7ec1:/# mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.29 MySQL Community Server (GPL)


mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |

6. make sure the firewall policy is active(run these cmd IN centos kuber OS, NOT in docker mysql image)

systemctl status iptables.service

7. use windows mysql tool to connect to db

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值