docker 运行mysql

https://www.cnblogs.com/sablier/p/11605606.html

https://www.jianshu.com/p/d6febf6f95e0

$ sudo yum install -y yum-utils \

  device-mapper-persistent-data \

  lvm2

$ sudo yum-config-manager \

    --add-repo \

    http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo

sudo yum install docker-ce docker-ce-cli containerd.io

sudo systemctl start docker

docker search mysql

mkdir -p /opt/docker-mysql/conf.d

mkdir -p /opt/docker-mysql/var/lib/mysql

cd /opt/docker-mysql/conf.d

vi config-file.cnf

[mysqld]

# 表名不区分大小写

lower_case_table_names=1

#server-id=1

datadir=/var/lib/mysql

#socket=/var/lib/mysql/mysqlx.sock

#symbolic-links=0

sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION

[mysqld_safe]

log-error=/var/log/mysqld.log

pid-file=/var/run/mysqld/mysqld.pid

docker run --name mysql \

    --restart=always \

    -p 3306:3306 \

    -v /opt/docker-mysql/conf.d:/etc/mysql/conf.d \

    -v /opt/docker-mysql/var/lib/mysql:/var/lib/mysql \

    -e MYSQL_ROOT_PASSWORD=123456-abc \

    -e TZ=Asia/Shanghai \

    -d mysql:latest

docker restart mysql

docker exec -it mysql bash

grant all PRIVILEGES on *.* to root@'%' WITH GRANT OPTION;

FLUSH PRIVILEGES;

1.docker images // 查看镜像

2.docker run 镜像名称  // 生成一个正在运行的容器实例

3.docker stop 容器名称  // 停止容器

4.docker rm 容器名称  // 删除容器

5.docker start 容器名称  // 启动容器

6.docker restart 容器名称  //重启容器

7.docker rmi 镜像名称  // 删除镜像

8.docker exec -it 容器名称 /bin/bash  // 进入容器

9.docker ps  // 显示正在运行的所有容器

10.docker ps -a  // 显示所有容器(包括已经停止的)

11.docker pull 镜像名称:版本号  // 拉取镜像

https://gitee.com/cailun-hx/cboot/tree/master

https://github.com/YunaiV/SpringBoot-Labs

https://blog.csdn.net/baidu_35800355/article/details/100045608?utm_medium=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-7.channel_param&depth_1-utm_source=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-7.channel_param

https://weread.qq.com/web/reader/73532be071e524ea73570d8ke2c32140247e2c420d92577

你可能感兴趣的:(docker 运行mysql)