Row x was cut by GROUP_CONCAT
http://www.forasp.cn/ 2023/4/13 17:07:36 点击:不统计
在使用mysql 分组连接 GROUP_CONCAT 出现了连接字符过长,导致的Row x was cut by GROUP_CONCAT
这个长度是配置项目,登录mysql 查看 GROUP_CONCAT 限制大小 group_concat_max_len
查看目前 GROUP_CONCAT 限制长度:
mysql> show variables like "group_concat_max_len";
+----------------------+-------+
| Variable_name | Value |
+----------------------+-------+
| group_concat_max_len | 1024 |
+----------------------+-------+
1 row in set (0.00 sec)
通过命令行临时设置GROUP_CONCAT 的长度,重启后,或者重新连接后失效。
SET GLOBAL group_concat_max_len = 102400; # 设置全局
SET SESSION group_concat_max_len = 102400; # 设置当前连接
执行命令如下
mysql> SET GLOBAL group_concat_max_len = 102400;
Query OK, 0 rows affected (0.00 sec)
mysql> SET SESSION group_concat_max_len = 102400;
Query OK, 0 rows affected (0.00 sec)
查看设置 GROUP_CONCAT长度后的结果:
mysql> show variables like "group_concat_max_len";
+----------------------+--------+
| Variable_name | Value |
+----------------------+--------+
| group_concat_max_len | 102400 |
+----------------------+--------+
1 row in set (0.00 sec)
如果不够长还可以继续重新设置大小。
第二种方法是在 修改配置文件 my.conf 中[mysqld]
添加:
group_concat_max_len = 102400