LoginSignup
44
40

More than 5 years have passed since last update.

Lost connection to MySQL server during query が出たときの対処

Last updated at Posted at 2012-12-26

 MySQL クライアントまたは mysqld サーバが max_allowed_packet バイトより大きいパケットを受け取った場合、Packet too large エラーが発生し、接続がクローズされます。

サーバ側の設定したのだけど、効いてないなと思ったら、

 クライアントとサーバには、共に独自の max_allowed_packet 変数があります。大きなパケットを扱う場合は、クライアントとサーバ両方の変数を増やす必要があります。

Clientも必要だということで…。

オプション指定ファイルに指定可能な項目は、次のURLに記載されています。
http://dev.mysql.com/doc/refman/4.1/ja/mysql-options.html

mysql>show variables like '%timeout%'

を実行し、次の値を確認します。

connect_timeout
interactive_timeout
net_read_timeout
wait_timeout

これらは秒数で指定されます。Lost connection エラーが出なくなるように調整します。

【追記:2013年1月8日】
なかなか、エラーがでなくなりません。
バックグランドジョブで実行すると出る可能性が低くなるような感じです。気のせいかも。

上URLを参考にしたが、発生しました。

con.ping(True)

今は、
net_read_timeout
net_write_timeout
を、600秒から3600秒に変更して様子を見ています。

44
40
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
44
40