无法在MySQL 5.5.25中设置max_allowed_pa​​cket

时间:2013-01-08 08:49:00

标签: mysql database

我无法在MYSQL命令提示符中设置“max_allowed_pa​​cket”变量,虽然我可以通过在my.ini文件中插入“max_allowed_pa​​cket = 100M”行来设置此值。为什么我有以下警告?

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>

我还尝试过以下小尺寸。

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版本

    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>

3 个答案:

答案 0 :(得分:6)

我注意到你必须使用1024的倍数来接受值:

值2048001失败:

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'

但值2048000有效:

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

manual说明了以下情况,但似乎'四舍五入'并不按设计工作:

  

该值应为1024的倍数;非四元组向下舍入   到最近的倍数。

答案 1 :(得分:3)

http://bugs.mysql.com/bug.php?id=22891http://bugs.mysql.com/bug.php?id=32223 结论是max_allowed_pa​​cket应该只是一个启动参数。

答案 2 :(得分:0)

answer1answer2很好,请检查一下。除此之外,当我们启动MySQL服务器时,我们得到一个全局默认值 max_allowed_packet,并且当初始化到服务器的连接时,这个全局默认值max_allowed_packet被复制到 local max_allowed_packet变量(只读),并由连接用于其操作。

因此,基本上,每台服务器重新启动后,您都需要输入

  

设置全局max_allowed_pa​​cket = 1048576000;

删除所有连接并开始新的连接,以便反映此新的全局值,现在您可以插入blob。