Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

max_allowed_packet could not be set in MySQL 5.5.25

Tags:

database

mysql

I could not set "max_allowed_packet" variable in MYSQL command prompt though I can set this value by inserting "max_allowed_packet=100M" line into my.ini file. Why I am having following warning?

mysql> SHOW VARIABLES LIKE 'max_allowed_packet';
+--------------------+---------+
| Variable_name      | Value   |
+--------------------+---------+
| max_allowed_packet | 1048576 |
+--------------------+---------+
1 row in set (0.00 sec)

mysql> warnings
Show warnings enabled.
mysql> set global max_allowed_packet=123456000;
Query OK, 0 rows affected, 1 warning (0.00 sec)

Warning (Code 1292): Truncated incorrect max_allowed_packet value: '123456000'
mysql> SHOW VARIABLES LIKE 'max_allowed_packet';
+--------------------+---------+
| Variable_name      | Value   |
+--------------------+---------+
| max_allowed_packet | 1048576 |
+--------------------+---------+
1 row in set (0.00 sec)

mysql>

I have alse tried smaller size as following.

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

Warning (Code 1292): Truncated incorrect max_allowed_packet value: '123456'
mysql>

mysql> set session max_allowed_packet=123456;
ERROR 1621 (HY000): SESSION variable 'max_allowed_packet' is read-only. Use SET GLOBAL to assign the value
Warning (Code 1292): Truncated incorrect max_allowed_packet value: '123456'
Error (Code 1621): SESSION variable 'max_allowed_packet' is read-only. Use SET GLOBAL to assign the value

MySQL Version

    mysql> SHOW VARIABLES LIKE "%version%";
+-------------------------+------------------------------+
| Variable_name           | Value                        |
+-------------------------+------------------------------+
| innodb_version          | 1.1.8                        |
| protocol_version        | 10                           |
| slave_type_conversions  |                              |
| version                 | 5.5.25                       |
| version_comment         | MySQL Community Server (GPL) |
| version_compile_machine | x86                          |
| version_compile_os      | Win64                        |
+-------------------------+------------------------------+
7 rows in set (0.00 sec)

mysql>
like image 281
Ahmet Karakaya Avatar asked Jan 08 '13 08:01

Ahmet Karakaya


People also ask

Where is max_allowed_packet in MySQL?

Open the "my. ini" file under the MySQL server install directory. Search for the "max_allowed_packet" parameter.

What is max allowed packet size in MySQL?

The largest possible packet that can be transmitted to or from a MySQL 8.0 server or client is 1GB.

Where can I find max_allowed_packet?

You have two values of max_allowed_packet in MySQL : one on the client side : [mysql] section, [mysqldump] , [client] and more. one on the server side : [mysqld] section.

What is max_allowed_packet MariaDB?

How does max_allowed_packet Function Work in MariaDB? Maximum size of max_allowed_packet is in bytes or it generates the intermediate string. In which we can set the packet message buffer value from the net_buffer_length but we can increase that value by using the max_allowed_packet bytes.


2 Answers

I noticed that you have to use multiples of 1024 for the values to be accepted:

A value of 2048001 fails:

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

Warning (Code 1292): Truncated incorrect max_allowed_packet value: '2048001'

But a value of 2048000 works:

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

The manual says the following, but it seems that the 'rounding down' does not work as designed:

The value should be a multiple of 1024; nonmultiples are rounded down to the nearest multiple.

like image 176
pfrenssen Avatar answered Oct 27 '22 01:10

pfrenssen


http://bugs.mysql.com/bug.php?id=22891 and http://bugs.mysql.com/bug.php?id=32223 where the conclusion was that max_allowed_packet should be a startup parameter only.

like image 36
Ahmet Karakaya Avatar answered Oct 26 '22 23:10

Ahmet Karakaya