MySQL中使用group

    xiaoxiao2023-10-05  164

     

    在使用group_concat的过程中遇到个问题,这里记录一下:在MySQL中有个配置参数group_concat_max_len,它会限制使用group_concat返回的最大字符串长度,默认是1024。

     

    查询group_concat_max_len大小:

    show variables like 'group_concat_max_len';

    修改group_concat_max_len大小:

    方法一:

    SET GLOBAL group_concat_max_len = 1024 * 10; SET SESSION group_concat_max_len = 1024 * 10;

    这种方法可以在不重启服务器的情况下使用,但是如果重启服务器后会还原配置。可以通过修改MySQL(my.ini)配置文件来彻底解决这个问题。

    方法二:

    修改MySQL(my.ini)配置文件,需要重启服务器后才能生效。

    找到my.ini文件,如果修改或新增:

    group_concat_max_len = 10240

    重启生效。

    最新回复(0)