docker-compose环境下搭建mysql8

version: "3"
services:
  mysql:
    container_name: mysql
    image: mysql:8.0.31-debian
    restart: always
    volumes:
      # 挂载mysql文件
      - ./mysql_data:/var/lib/mysql
      # 挂载mysql配置
      - ./mysql_cnf:/etc/mysql
      # 挂载mysql错误日志
      - ./mysql_error_log:/var/log
    ports:
     - "8806:3306"
    environment:
      TZ: Asia/Shanghai
      MYSQL_ROOT_PASSWORD: root
    command:
      --character-set-server=utf8mb4
      --collation-server=utf8mb4_unicode_ci
      --max_connections=2000
      --wait_timeout=20000

你可能感兴趣的:(Docker,mysql,docker,mysql,容器)