【全栈开发指南】Mysql8 开启远程登录(docker-compose安装 )

一、登录并配置mysql

  1. 登录容器
docker exec -it 53e85183fdc0 /bin/bash
  1. 编辑文件
vim   /etc/mysql/conf.d/docker.cnf
  1. 增加 skip-grant-tables
skip-grant-tables
  1. 重启容器
docker-compose -f docker-compose.yml restart
  1. 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
  1. 修改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
  1. 重启mysql
 docker restart [mysql容器名称或ID]

猜你喜欢

转载自blog.csdn.net/wmz1932/article/details/131666302
今日推荐