docker yml mysql_docker-compose.yml 快速搭建mysql数据库

  • Post author:
  • Post category:mysql

通过docker-compose快速搭建数据库,并且修改相关字符集为utf8mb4

vi docker-compose.yml

version: ‘2’

services:

mysql:

image: mysql:5.7.22

restart: always

container_name: mysql

volumes:

– ./mysql:/var/lib/mysql

– ./conf:/etc/mysql

– /etc/localtime:/etc/localtime

environment:

– TZ=Asia/Shanghai

– MYSQL_ROOT_PASSWORD=123456

ports:

– 13506:3306

#network_mode: ‘host’

#数据库删减版配置文件

vi ./conf/my.cnf

[mysql]

default-character-set = utf8mb4

[client]

default-character-set = utf8mb4

[mysqld]

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

socket = /var/run/mysqld/mysqld.sock

datadir = /var/lib/mysql

symbolic-links=0

character-set-server = utf8mb4

#sql模块修改

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

#允许最大传输文件大小

max_allowed_packet = 1G


版权声明:本文为weixin_39875516原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。