赞
踩
mysql默认的配置sql_mode包含ONLY_FULL_GROUP_BY,之前一直是启动容器以后进入容器进行修改,非常不方便,而且重启又得重新设置。
后面找到一篇文章写的不错,直接用配置文件配置,把配置文件映射到容器目录即可
新建文件,放到/data/docker/mysql3306/conf
vim custom.cnf
[mysqld]
sql_mode='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION'
version: '3'
services:
mysql-localhost:
image: 'mysql:8.0'
network_mode: host
container_name: mysql
restart: always
privileged: true
environment:
MYSQL_ROOT_PASSWORD: "you_pwd"
volumes:
- '/data/docker/mysql3306/log:/var/log/mysql'
- '/data/docker/mysql3306/data:/var/lib/mysql'
- '/data/docker/mysql3306/conf:/etc/mysql/conf.d'
- '/etc/localtime:/etc/localtime'
重启容器
sudo docker-compose up -d
验证sql_mode是否生效
select @@sql_mode
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。