1. Log in and configure mysql
- Login container
docker exec -it 53e85183fdc0 /bin/bash
- Edit file
vim /etc/mysql/conf.d/docker.cnf
- Add skip-grant-tables
skip-grant-tables
- Restart container
docker-compose -f docker-compose.yml restart
- Mysql8 adds new users and does not support 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;
2. Solve the group by problem
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
- Modify the mysql configuration file /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
- Restart mysql
docker restart [mysql容器名称或ID]