mysql 5.7.9 插入数据异常,异常如下。

[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

在 /etc/my.cnf 文件里加上如下:

sql_mode='NO_ENGINE_SUBSTITUTION',然后重启Mysql服务就可以了。

一、异常信息:

errorCode:1366 Caused by: java.sql.SQLException: Incorrect string value: '\xE7\xAE...' for column 'description' at row 1

二、异常原因:

(1)、字符集冲突,mysql insert入库的时候,由于插入数据编码与数据库字段字符集不一致,导致数据无法插入。

(2)、在mysql数据库中执行show character set,可以看到不同的字符集的最大长度不同。如果执插入utf8编码数据,数据库表中字段字符集是latin。(查询字段字符集方法:show full columns from user;),如果最大长度为3的utf8字符集存储到最大长度为1的latin数据库字段中,数据会被截断,无法正常插入,导致异常。

温馨提示:答案为网友推荐,仅供参考
第1个回答  2017-12-29

在my.cnf 里面设置

在sql mode 中去掉only  full  group  by 。

详细解释:

1、执行如下命令连接本地mysql服务器。

mysql -u 用户名 -p 密码

2、执行如下命令即可获取数据库物理文件的存放位置。

show variables like ‘datadir''; 

说明:图中显示的数据库物理存储位置在/var/lib/mysql。