search

Home  >  Q&A  >  body text

python - 时不时出现 (2013, 'Lost connection to MySQL server during query')

报错内容:

modles:

my.cn中
max_allowed_packet=1024M
skip-name-resolve

还是经常出现(2013, 'Lost connection to MySQL server during query')这个错误

请问哪里出问题了,应该怎么修改呢

PHP中文网PHP中文网2781 days ago761

reply all(3)I'll reply

  • PHPz

    PHPz2017-04-18 10:26:01

    It is recommended that when asking questions, try to post the error message and the error code instead of taking screenshots.

    The error message indicates that the mysql connection is lost.

    search_cursor = search_conn.cursor()

    Seeing that your list_related function did not pass in the search_conn parameter, did you define it as a global variable? If this is the case, it is because mysql has a default connect_timeout time, which will automatically close the connection once it is exceeded.

    You can try the following two methods:

    1. Set the connect_timeout time when creating a connection and set it longer.

    2. Every time you operate the database, a connection is established and closed after the operation is completed.

    reply
    0
  • 黄舟

    黄舟2017-04-18 10:26:01

    Judging from your SQL statement, it is not well written. You need to study it carefully and make full use of indexes or third-party word segmentation systems

    reply
    0
  • PHP中文网

    PHP中文网2017-04-18 10:26:01

    Django’s ORM is not easy to use?

    reply
    0
  • Cancelreply