1、mysql版本就选择5.7吧

docker pull mysql:5.7			#拉取镜像
docker run -id --name mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=123456 mysql:5.7	#启动容器,root密码是必须指定的

在这里插入图片描述
2、在宿主机安装mysql-client客户端

rpm -e mariadb-libs-5.5.68-1.el7.x86_64 --nodeps		#卸载mariadb数据库
yum -y install https://mirrors.tuna.tsinghua.edu.cn/mysql/downloads/MySQL-5.7/mysql-community-common-5.7.37-1.el7.x86_64.rpm
yum -y install https://mirrors.tuna.tsinghua.edu.cn/mysql/downloads/MySQL-5.7/mysql-community-libs-5.7.37-1.el7.x86_64.rpm
yum -y install https://mirrors.tuna.tsinghua.edu.cn/mysql/downloads/MySQL-5.7/mysql-community-client-5.7.37-1.el7.x86_64.rpm

3、连接数据库

mysql -uroot -p123456 -h127.0.0.1		#必须指定主机名不能无法连接

在这里插入图片描述

Logo

腾讯云面向开发者汇聚海量精品云计算使用和开发经验,营造开放的云计算技术生态圈。

更多推荐