初级 - mysql 安装

1、mysql 概述

2、mysql 安装

2.1、linux 上 docker-compose 安装 mysql 5.7

  • docker-compose.yml 文件

version: '3.7'
services:
  mysql:
    image: mysql:5.7
    container_name: "mysql"
    restart: always
    ports:
      - 3306:3306
    command: ['mysqld', '--character-set-server=utf8mb4', '--collation-server=utf8mb4_unicode_ci']
    environment:
        TZ: "Asia/Shanghai"
        MYSQL_ROOT_PASSWORD: "123456"                        # root 初始默认密码
    volumes:
      - "./mysql_data/db:/var/lib/mysql"                          # db 用来存放了数据库表文件
      - "./mysql_data/conf.d:/etc/mysql/conf.d"                   # 存放自定义的配置文件
      - "./mysql_data/init:/docker-entrypoint-initdb.d/"          # init 存放初始化的脚本
    logging:
      driver: "json-file"
      options:
        max-size: "10M"
#    deploy:
#      resources:
#        limits:
#          cpus: '1.00'
#          memory: 2G

2.2、linux 上 docker-compose 安装 mysql 8.0

version: '3.7'
services:
  mysql:
    image: mysql:8.0
    container_name: "mysql"
    restart: always
    ports:
      - 3306:3306
    environment:
        TZ: "Asia/Shanghai"
        MYSQL_ROOT_PASSWORD: "123456"                        # root 初始默认密码
    volumes:
      - "./mysql_data/db:/var/lib/mysql"                          # db 用来存放了数据库表文件
      - "./mysql_data/conf.d:/etc/mysql/conf.d"                   # 存放自定义的配置文件
      - "./mysql_data/init:/docker-entrypoint-initdb.d/"          # init 存放初始化的脚本
    logging:
      driver: "json-file"
      options:
        max-size: "10M"
#    deploy:
#      resources:
#        limits:
#          cpus: '1.00'
#          memory: 2G
posted @ 2023-03-14 14:16  海兵的正义  阅读(20)  评论(0编辑  收藏  举报