当前位置:Gxlcms > 数据库问题 > mysql:group_concat()长度限制

mysql:group_concat()长度限制

时间:2021-07-01 10:21:17 帮助过:24人阅读

GROUP_CONCAT() 是有最大长度限制的,默认值是 1024

SHOW VARIABLES LIKE ‘group_concat_max_len‘

技术图片
可以通过 group_concat_max_len 参数进行动态设置。参数范围可以是 Global 或 Session。

格式:SET [GLOBAL|SESSION] group_concat_max_len=val

val值是无符号整型,最大值与版本位数有关:

mysql版本号 最小值 最大值 备注
32 位 4 4294967295 2^32
64 位 4 18446744073709551615 2^64)

设置32位mysql最大值

    SET GLOBAL group_concat_max_len = 4294967295;
或
SET SESSION group_concat_max_len = 4294967295;

设置64位mysql最大值

SET GLOBAL group_concat_max_len = 18446744073709551615;
或
SET SESSION group_concat_max_len = 18446744073709551615;

有效最大长度受max_allowed_packet的值约束,默认值为4M

查看目前配置

show VARIABLES like ‘%max_allowed_packet%‘;

技术图片

方案1:修改配置文件my.cnf:(推荐方式)
在[mysqld]段新增如下:
    max_allowed_packet = 20M

技术图片

方案2:mysql命令
在mysql 命令行中运行
    set global max_allowed_packet = 2*1024*1024*10
    然后退出命令行,重启mysql服务
    查看是否修改成功
    show VARIABLES like ‘%max_allowed_packet%‘

mysql:group_concat()长度限制

标签:global   pack   mamicode   pac   符号   整型   运行   64位   sql   

人气教程排行