[Full-stack Development Guide] Enable remote login for Mysql8 (docker-compose installation)

1. Log in and configure mysql

  1. Login container
docker exec -it 53e85183fdc0 /bin/bash
  1. Edit file
vim   /etc/mysql/conf.d/docker.cnf
  1. Add skip-grant-tables
skip-grant-tables
  1. Restart container
docker-compose -f docker-compose.yml restart
  1. 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
  1. 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
  1. Restart mysql
 docker restart [mysql容器名称或ID]

Guess you like

Origin blog.csdn.net/wmz1932/article/details/131666302
Recommended