全部文章/数据库

mysql常见报错

mysql使用过程中常见报错处理

一 ,远程连接报错1130

搭建好的mysql使用本地打开没有问题,当使用远程工具连接是报错

错误代码:1130 host is not allowed to connect to this mysql server

解决办法

使用mysql数据库

更改数据

update user set host ='%' where user = 'root';

FLUSH PRIVILEGES;

如果报错:ERROR 1062 (23000): Duplicate entry ‘%-root’ for key ‘PRIMARY’

使用:select host from user where user = 'root';
则是已经有过了。 ### 二,在写入中文数据报错1366 出现错误代码:1366 - Incorrect string value: '\xE7\x94\xB7' for column '' at row 1

可以修改具体列中的设置为utf8

或者

show variables like ‘character%’;

将server database改为utf8

set character_set_database=utf8;
  ### 三,报错1055

1055 - Expression #3 of SELECT list is not in GROUP BY clause and contains nonaggregated column ’test_1.a.score’ which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by

本以为是代码写错了,就没有理会,后来百度了一下才了解到sql标准中不允许select列表,having条件语句,或order by语句中出现group by 中未列表的可聚合列,ONLY_FULL_GROUP_BY 默认为开启

SELECT @@sql_mode; 可以查看

建议使用如下方法解决

SET SESSION sql_mode=(SELECT REPLACE(@@sql_mode,‘ONLY_FULL_GROUP_BY,’,’’));