How to change max_allowed_packet size in MySQL?


The max_allowed_packet size is a session variable and is also a read only variable.

To check what is the present value of max_allowed_packet, the command show variables is used. It is given as follows −

mysql> show variables like 'max_allowed_packet';

The following is the output

+--------------------+---------+
| Variable_name      | Value   |
+--------------------+---------+
| max_allowed_packet | 4194304 |
+--------------------+---------+
1 row in set (0.04 sec)

The value of the max_allowed_packet can be changed in the ‘my.ini’ file on the client side. The query for that is given as follows −

max_allowed_packet = 4567890;

Now, the value can be changed globally with the help of the following query −

mysql> set global max_allowed_packet=456789;
Query OK, 0 rows affected, 1 warning (0.00 sec)

After restarting the server, we will get the changed value.

Updated on: 24-Jun-2020

2K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements