返回列表 发布新帖

[玩法教程] 分享几个个人长期自用的docker——数据库

290 0
发表于 2026-4-29 12:29:06 | 查看全部 阅读模式 IP:–江苏–苏州

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?立即注册

×
默认初始化逻辑:
数据库字符集为utf8,排序规则为utf8_general_ci,innodb_buffer_pool_size指定系统内存的1/4,max_connections方便压测设置,sql_mode默认NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES,使用长索引类型

MySQL:
MySQL57:

  1. version: '3.8'

  2. services:
  3.   mysql-5.7:
  4.     image: mysql:5.7.36
  5.     container_name: mysql-5.7
  6.     platform: linux/amd64
  7.     restart: always
  8.     ports:
  9.       - "3305:3306"
  10.     environment:
  11.       - MYSQL_ROOT_PASSWORD=Zhs991004
  12.       - TZ=Asia/Shanghai
  13.     command:
  14.       - --character-set-server=utf8
  15.       - --collation-server=utf8_general_ci
  16.       - --innodb_buffer_pool_size=512M
  17.       - --log_bin_trust_function_creators=1
  18.       - --lower_case_table_names=1
  19.       - --max_connections=5000
  20.       - --sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
  21.       - --transaction_isolation=READ-COMMITTED
  22.       - --group_concat_max_len=102400
  23.     volumes:
  24.       - ./data:/var/lib/mysql
  25.       - ./log:/var/log/mysql
  26.       - /etc/timezone:/etc/timezone:ro
  27.       - /etc/localtime:/etc/localtime:ro
复制代码

MySQL80
  1. version: '3.8'

  2. services:
  3.   mysql-8.0:
  4.     image: mysql:8.0.34
  5.     container_name: mysql-8.0
  6.     platform: linux/amd64
  7.     restart: always
  8.     ports:
  9.       - "3306:3306"
  10.     environment:
  11.       - MYSQL_ROOT_PASSWORD=Zhs991004
  12.       - TZ=Asia/Shanghai
  13.     command:
  14.       - --character-set-server=utf8
  15.       - --collation-server=utf8_general_ci
  16.       - --innodb_buffer_pool_size=512M
  17.       - --log_bin_trust_function_creators=1
  18.       - --lower_case_table_names=1
  19.       - --max_connections=5000
  20.       - --sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
  21.       - --transaction_isolation=READ-COMMITTED
  22.       - --group_concat_max_len=102400
  23.       - --default-authentication-plugin=mysql_native_password
  24.     volumes:
  25.       - ./data:/var/lib/mysql
  26.       - ./log:/var/log/mysql
  27.       - /etc/timezone:/etc/timezone:ro
  28.       - /etc/localtime:/etc/localtime:ro
复制代码

Postgre SQL:
默认15(商用免费)
  1. version: '3.8'

  2. services:
  3.   postgres-db:
  4.     image: postgres:15
  5.     container_name: postgres-db
  6.     restart: always
  7.     ports:
  8.       - "15432:5432"
  9.     environment:
  10.       - POSTGRES_PASSWORD=Zhs991004
  11.       - POSTGRES_USER=postgres
  12.       - POSTGRES_DB=ecology
  13.       - TZ=Asia/Shanghai
  14.       # 替代 MySQL 的 character-set-server=utf8 和 collation-server=utf8_general_ci
  15.       - POSTGRES_INITDB_ARGS=--encoding=UTF8 --lc-collate=C --lc-ctype=C
  16.     command:
  17.       - "postgres"
  18.       - "-c"
  19.       - "shared_buffers=512MB"
  20. - "-c"
  21.       - "max_connections=1000"
  22. - "-c"
  23.       - "default_transaction_isolation=read committed"
  24.       - "-c"
  25.       - "timezone=Asia/Shanghai"
  26.     volumes:
  27.       - ./data:/var/lib/postgresql/data
  28.       - /etc/timezone:/etc/timezone:ro
  29.       - /etc/localtime:/etc/localtime:ro
复制代码




评论

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Copyright © 2026 绿联NAS私有云社区 版权所有 All Rights Reserved. 粤公网安备44030002002555号| 粤ICP备12028978号
关灯 在本版发帖
联系技术支持
返回顶部
快速回复 返回顶部 返回列表