mysql:group_concat()長度限制

GROUP_CONCAT() 是有最大長度限制的,默認值是 1024mysql

SHOW VARIABLES LIKE 'group_concat_max_len'

mysql:group_concat()長度限制
能夠經過 group_concat_max_len 參數進行動態設置。參數範圍能夠是 Global 或 Session。sql

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

val值是無符號整型,最大值與版本位數有關:markdown

mysql版本號 最小值 最大值 備註
32 位 4 4294967295 2^32
64 位 4 18446744073709551615 2^64)

設置32位mysql最大值ide

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的值約束,默認值爲4M3d

查看目前配置code

show VARIABLES like '%max_allowed_packet%';

mysql:group_concat()長度限制

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

mysql:group_concat()長度限制

方案2:mysql命令
在mysql 命令行中運行
    set global max_allowed_packet = 2*1024*1024*10
    而後退出命令行,重啓mysql服務
    查看是否修改爲功
    show VARIABLES like '%max_allowed_packet%'
相關文章
相關標籤/搜索