3

I want to increase max_allowed_packet variable size for MySQL client which is using remote server. I've Googled it and the answers I could find only discussed changing the variable for server.

My client program is MySQL Workbench for Windows 7.

1 Answer 1

3

According to MySQL Documentation on max_allowed_packet

Some programs such as mysql and mysqldump enable you to change the client-side value by setting max_allowed_packet on the command line or in an option file.

On the command line, to set it to 512M just run mysql client with this:

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)

You have to set it globally. You cannot set it locally.

You need the SUPER privilege to set any global variable.

2
  • when i try this command i got error like ERROR 1621 (HY000): SESSION variable 'max_allowed_packet' is read-only. Use SET GLOBAL to assign the value
    – MONTYHS
    Commented Feb 17, 2014 at 14:58
  • @MONTYHS Please read my answer real carefully. I already ran set max_allowed_packet=1024 * 1024 * 512;, showed the error message, ran set global max_allowed_packet=1024 * 1024 * 512; successfully, and then said You have to set it globally. You cannot set it locally. . Therefore, my answer is thorough and complete and has been that way since May 3, 2012. Commented Feb 17, 2014 at 16:03

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .