docker 中操作mysql 遇到的问题

mysql5.7
遇到这么个问题:

[Err] 1055 - Expression #1 of ORDER BY clause is not in GROUP BY clause and contains nonaggregated column 'information_schema.PROFILING.SEQ' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by

解决办法:

1、进入容器

docker exec -it 容器name或id /bin/bash
我这里的容器name是mysql。所以:docker exec -it mysql /bin/bash

2、修改/etc/mysql/mysql.conf.d/mysqld.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

3、退出容器,然后重启容器
docker restart 容器name或id
也就是docker restart mysql

如果修改配置文件出错了,那么这个容器将启动失败,怎么办呢?
思路是将容器中的配置文件拿出来,修改正确后放回去。
1、将容器中的配置文件取出来,放到d盘

docker cp 容器name或id:/etc/mysql/mysql.conf.d/mysqld.cnf d:/mysql.cnf

2、将取出来的文件mysql.cnf,修改正确后放回去

docker cp d:/mysql.cnf 容器name或id:/etc/mysql/mysql.conf.d/mysqld.cnf

3、重启容器
docker restart 容器name或id

sudo docker run --name mysql -p 3606:3306 -e MYSQL_ROOT_PASSWORD=123456 -d -v /home/mantishell/mysql/:/var/lib/mysql mysql --lower_case_table_names=1

docker run --name mysq.db -p 3306:3306 -e MYSQL_ROOT_PASSWORD=123456 -d -v /home/mysql/:/var/lib/mysql mysql --lower_case_table_names=1

sudo docker cp mysql8:/etc/mysql/conf.d/mysql .

posted @ 2020-06-30 22:41  mantishell  阅读(693)  评论(0编辑  收藏  举报