クライアントの mysql max_allowed_pa​​cket を増やすにはどうすればいいですか?

クライアントの mysql max_allowed_pa​​cket を増やすにはどうすればいいですか?

リモート サーバーを使用している MySQL クライアントの変数サイズを増やしたいですmax_allowed_packet。Google で検索しましたが、見つかった回答はサーバーの変数を変更することのみを扱っていました。

私のクライアント プログラムは、MySQL Workbench for Windows 7 です。

答え1

によると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特権グローバル変数を設定します。

関連情報