MySQL server has gone away during crawling in Perl

前端 未结 3 1987
耶瑟儿~
耶瑟儿~ 2021-01-23 22:44

I use WWW::Mechanize library to get the content of URLs and save their data into mysql tables. But when the page\'s content is too large, it gives this error message:

相关标签:
3条回答
  • 2021-01-23 23:18

    You might want to look at DBIx::Connector. From the docs:

    You can store the connection somewhere in your app where you can easily access it, and for as long as it remains in scope, it will try its hardest to maintain a database connection. Even across forks (especially with DBI 1.614 and higher) and new threads, and even calls to $conn->dbh->disconnect. When you don't need it anymore, let it go out of scope and the database connection will be closed.

    0 讨论(0)
  • 2021-01-23 23:22

    Try to add

    max_allowed_packet=32M
    

    in MySQL configuration file

    0 讨论(0)
  • 2021-01-23 23:26

    Are you using the latest DBI and DBD::mysql? It should have mysql_auto_reconnect enabled.

    If you're using mysql under forks, you may need to set

    $dbh->{InactiveDestroy} = 1;
    
    0 讨论(0)
提交回复
热议问题