我使用 python 连接到 mysql 数据库 con = _mysql.connect('localhost', 'dell-pc', '', 'test')
我编写的程序完全执行需要很多时间,即大约 10 个小时.实际上,我正在尝试从语料库中读取不同的单词.读取完成后出现超时错误.
I connected to a mysql database using python con = _mysql.connect('localhost', 'dell-pc', '', 'test')
The program that I wrote takes a lot of time in full execution i.e. around 10 hours. Actually, I am trying to read distinct words from a corpus.
After reading was finished there was a timeout error.
我检查了 Mysql 默认超时时间:
I checked Mysql default timeouts which were:
+----------------------------+----------+
| Variable_name | Value |
+----------------------------+----------+
| connect_timeout | 10 |
| delayed_insert_timeout | 300 |
| innodb_lock_wait_timeout | 50 |
| innodb_rollback_on_timeout | OFF |
| interactive_timeout | 28800 |
| lock_wait_timeout | 31536000 |
| net_read_timeout | 30 |
| net_write_timeout | 60 |
| slave_net_timeout | 3600 |
| wait_timeout | 28800 |
+----------------------------+----------+
如何更改默认超时时间?
How can I change the default timeout ?
做:
con.query('SET GLOBAL connect_timeout=28800')
con.query('SET GLOBAL interactive_timeout=28800')
con.query('SET GLOBAL wait_timeout=28800')
参数含义(取自 MySQL Workbench in Navigator:Instance > Options File > Tab Networking" > Section Timeout Settings")
Parameter meaning (taken from MySQL Workbench in Navigator: Instance > Options File > Tab "Networking" > Section "Timeout Settings")
顺便说一句:28800 秒是 8 小时,因此对于 10 小时的执行时间,这些值实际上应该更高.
BTW: 28800 seconds are 8 hours, so for a 10 hour execution time these values should be actually higher.
这篇关于通过python连接时如何更改默认的Mysql连接超时?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!