一、登录并配置mysql
- 登录容器
docker exec -it 53e85183fdc0 /bin/bash
- 编辑文件
vim /etc/mysql/conf.d/docker.cnf
- 增加 skip-grant-tables
skip-grant-tables
- 重启容器
docker-compose -f docker-compose.yml restart
- mysql8新增用户,已不支持GRANT ALL PRIVILEGES ON . TO ‘root’@‘%’
create user 'admin'@'%' identified by '数据库密码';
GRANT ALL PRIVILEGES ON *.* TO 'admin'@'%';
flush privileges;
ALTER USER 'admin'@'%' IDENTIFIED WITH mysql_native_password BY '数据库密码';
flush privileges;
二、解决group by问题
java.sql.SQLSyntaxErrorException: Expression #14 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'yxkt.provinceDistrict.name' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by
- 修改mysql配置文件 /etc/mysql/conf.d/my.cnf
vim /etc/mysql/conf.d/my.cnf
sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
- 重启mysql
docker restart [mysql容器名称或ID]