这两天写了一个 Console 程序,批量处理数据库,本来运行得好好的,突然就不行了,异常提示是:  

The timeout period elapsed prior to completion of the operation or the server is not responding.


查看了好多技术文档,先是发现  net_read_timeout = 30    net_write_timeout = 60 
试着将这两项改大(在my.ini 的mysqld小节),结果没有效果

最后发现在 .net 的 connectstring 中有 comandtimeout 设置,如:
string conn = "Database=XX;Data Source=localhost;User Id=root;Password=mykey;default command timeout = 30000";
再运行,发现真的好了!  (此处单位是秒)

如果数据量很小,就不一定是超时,而有可能是表被锁定了
posted on 2012-09-18 22:08  精思入神  阅读(636)  评论(0编辑  收藏  举报