Technology Encyclopedia Home >How to adjust the group_concat_max_len parameter in MySQL?

How to adjust the group_concat_max_len parameter in MySQL?

To adjust the group_concat_max_len parameter in MySQL, you can modify it either dynamically for the current session or permanently by updating the configuration file.

  1. Dynamic Adjustment (Session-Level):
    Use the SET statement to change the value for the current session. This change only affects the current connection and resets after the session ends.
    Example:

    SET SESSION group_concat_max_len = 1000000;
    

    To apply it globally for all new sessions (but requires SUPER privilege):

    SET GLOBAL group_concat_max_len = 1000000;
    
  2. Permanent Adjustment (Configuration File):
    Edit the MySQL configuration file (my.cnf or my.ini depending on the OS) and add or update the parameter under the [mysqld] section.
    Example:

    [mysqld]
    group_concat_max_len = 1000000
    

    After saving the file, restart the MySQL service to apply the changes.

If you're using Tencent Cloud Database MySQL, you can adjust this parameter via the Tencent Cloud Console:

  • Navigate to the Database Management page.
  • Select your MySQL instance and go to Parameters.
  • Search for group_concat_max_len, modify its value, and save. The change may require a restart of the instance.

For temporary adjustments in Tencent Cloud, use the SET command as shown above.