All Products
Search
Document Center

:How do I modify the max_allowed_packet parameter value of MySQL?

Last Updated:Dec 31, 2020

Overview

This paper mainly elaborates how to modify the MySQL max_allowed_packet parameter value .

Detail

Alibaba Cloud reminds you that:

  • Before you perform operations that may cause risks, such as modifying instance configurations or data, we recommend that you check the disaster recovery and fault tolerance capabilities of the instances to ensure data security.
  • You can modify the configurations and data of instances including but not limited to Elastic Compute Service (ECS) and Relational Database Service (RDS) instances. Before the modification, we recommend that you create snapshots or enable RDS log backup.
  • If you have authorized or submitted sensitive information such as the logon account and password in the Alibaba Cloud Management Console, we recommend that you modify such information in a timely manner.

Two methods can be used to modify the max_allowed_packet parameter of MySQL. Call the following operations:

  • Modify the MySQL configuration file
  1. Run the following command to edit the my.cn f configuration file:
    vi my.cnf
  2. Add the following parameters to the mysqld] configuration item. For more information about the parameter values, see.
    max_allowed_packet=32M
  3. Save the file modifications and restart the MySQL database for the changes to take effect.
  • Modify the password in the MySQL database.
  1. Run the following command to log on to the database:
    mysql -u [$Username] -p
    Note:[$Username] is your database user name. You can enter your password to log on to the database.
  2. Run the following SQL statement to modify parameters:
    set global max_allowed_packet = 32M# sets the parameter to 32 MB.

Application scope

  • Elastic Compute Service