赞
踩
官方文档:Install Docker Engine on CentOS | Docker Docs
docker-client \
docker-client-latest \
docker-common \
docker-latest \
docker-latest-logrotate \
docker-logrotate \
docker-engine
sudo yum install -y yum-utils
sudo yum-config-manager \
--add-repo \
https://download.docker.com/linux/centos/docker-ce.repo
sudo yum install docker-ce docker-ce-cli containerd.io docker-compose-plugin
sudo systemctl start docker
mkdir -p /var/data/mysql/data
mkdir -p /var/data/mysql/log
docker安装mysql5.7,挂载配置文件_docker mysql5.7 配置文件-CSDN博客
在主机上述新建的文件夹中:/var/data/mysql/conf添加my.cnf文件
准备映射到小容器中的/etc/mysql/mysql.conf.d/my.cnf
user=mysql
character-set-server=utf8
default_authentication_plugin=mysql_native_password
secure_file_priv=/var/lib/mysql
expire_logs_days=7
sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION
max_connections=1000
[client]
default-character-set=utf8
[mysql]
default-character-set=utf8
docker下安装mysql5.7教程_docker安装mysql5.7-CSDN博客
docker run -p 3306:3306 --name mysql57 \
-v /var/data/mysql/conf:/etc/mysql/mysql.conf.d \
-v /var/data/mysql/log:/var/log/ \
-v /var/data/mysql/data:/var/lib/mysql \
-e MYSQL_ROOT_PASSWORD=123456 \
-d mysql:5.7
https://blog.csdn.net/m0_53623945/article/details/124961650
# 3.建镜像
# -p 端口映射 本机端口:容器端口
# --name:给MySQL容器取的名字
# -d:表示后台运行
# -e MYSQL_ROOT_PASSWORD:设置root用户密码
# -v:表示挂载路径,冒号左面的表示宿主机的挂载目录,冒号右边则表示容器内部的路径。
如何远程连接云服务器docker创建的mysql数据库_docker mysql 远程连接-CSDN博客
docker exec -it mysql57 bash
# -u后接账户 -p接密码
mysql -uroot -p123456
# 外网范围授权
grant all privileges on *.* to root@'%' identified by "123456";
# 刷新权限
flush privileges;
# 一定要更新密码,否则Navicat连接报1045错误
alter user 'root'@'%' identified with mysql_native_password by '123456';
# 刷新权限
flush privileges;
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。