如何为客户端增加mysql max_allowed_pa​​cket?


3

我想为使用远程服务器的mysql客户端增加max_allowed_pa​​cket变量大小。我用谷歌搜索了它,我找到的答案只讨论了改变服务器的变量。

我的客户端程序是适用于Windows 7的MySql Workbench。

Answers:


2

根据max_allowed_pa​​cket上的MySQL文档

某些程序(如mysql和mysqldump)允许您通过在命令行或选项文件中设置max_allowed_pa​​cket来更改客户端值。

在命令行上,将其设置为512M只需运行mysql客户端:

C:\>mysql -u... -p...

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 31
Server version: 5.5.12-log MySQL Community Server (GPL)

Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> show variables like 'max_allowed_packet';
+--------------------+----------+
| Variable_name      | Value    |
+--------------------+----------+
| max_allowed_packet | 16777216 |
+--------------------+----------+
1 row in set (0.00 sec)

mysql> set max_allowed_packet=1024 * 1024 * 512;
ERROR 1621 (HY000): SESSION variable 'max_allowed_packet' is read-only. Use SET GLOBAL to assign the value
mysql> set global max_allowed_packet=1024 * 1024 * 512;
Query OK, 0 rows affected (0.00 sec)

mysql> show variables like 'max_allowed_packet';
+--------------------+----------+
| Variable_name      | Value    |
+--------------------+----------+
| max_allowed_packet | 16777216 |
+--------------------+----------+
1 row in set (0.00 sec)

mysql> exit
Bye

C:\>mysql -u... -p...
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 32
Server version: 5.5.12-log MySQL Community Server (GPL)

Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> show variables like 'max_allowed_packet';
+--------------------+-----------+
| Variable_name      | Value     |
+--------------------+-----------+
| max_allowed_packet | 536870912 |
+--------------------+-----------+
1 row in set (0.00 sec)

你必须全局设置它。您无法在本地设置它。

您需要SUPER权限才能设置任何全局变量。


当我尝试这个命令时,我收到错误,如ERROR 1621(HY000):SESSION变量'max_allowed_pa​​cket'是只读的。使用SET GLOBAL分配值
MONTYHS 2014年

@MONTYHS请仔细阅读我的回答。我已经跑了set max_allowed_packet=1024 * 1024 * 512;,显示错误信息,set global max_allowed_packet=1024 * 1024 * 512;成功运行,然后说You have to set it globally. You cannot set it locally.。因此,我的答案是彻底和完整的,自2012
RolandoMySQLDBA 2014年
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.