100215  9:55:47 [Warning] Aborted connection 247 to db: 'gases' user: 'root' host: 'localhost' (Got an error reading communication packets)
100215  9:55:47 [Warning] Aborted connection 257 to db: 'gases' user: 'root' host: 'localhost' (Got an error reading communication packets)
100215  9:56:02 [Warning] Aborted connection 277 to db: 'gases' user: 'root' host: 'localhost' (Got an error reading communication packets)
100215  9:56:02 [Warning] Aborted connection 275 to db: 'gases' user: 'root' host: 'localhost' (Got an error reading communication packets)
100215 10:04:46 [Warning] Aborted connection 718 to db: 'gases' user: 'root' host: 'localhost' (Got an error reading communication packets)mysql的连接经常断掉,就是在本机连接的,如果是程序问题那么更换任意一台别的电脑都没有问题,应该不是程序问题吧?我的配置如下:
[mysqld]
port=3306
skip-locking
log_warnings
slow_query_log
log-error = "C:/Program Files/MySQL/MySQL Server 5.1/logs"
max_allowed_packet = 64M
back_log = 900
max_connect_errors = 100
long_query_time = 2
log_long_format
wait_timeout = 68800
interactive_timeout = 68800
federated
net_read_timeout=120
max_connections=1024
table_cache=500
open-files-limit=2048有点怀疑是服务器环境的关系,已经重新安装服务器,但是还是有问题,当然服务器上还有一些别的软件例如sql server 、iis、360安全卫士、等,想请问一下怎样追踪mysql的这个连接中断的问题?我安装到别的机器上都没有类似问题,只有这台服务器上有问题,我想问问,“Got an error reading communication packets” 这句话是什么意思?是指mysql出现问题了导致通讯问题呢?还是通讯问题导致mysql连接中断?哎,这个提示百思不得其解,请高人指点迷津!

解决方案 »

  1.   

    1.增大max_allowed_packet对应的数值试一下2.好好优化一下SQL语句让他不要返回大的结果集的好 如果有大的结果集 建议用sql_big_result
    参考http://dev.mysql.com/doc/refman/5.0/en/communication-errors.html
      

  2.   

    使用本机的TCP连接试试(连接到IP地址127.0.0.1)。
      

  3.   

    问题还是依然存在,各位,真的不知道什么原因,这次我可以提供更详细的信息如下:
    环境windows server 2003 + mysql 5.1.43  问题主要体现在mysql的连接经常中断,打开mysql日志,错误信息如下:100223 21:32:23 [Warning] Aborted connection 43666 to db: 'gases' user: 'root' host: 'localhost' (Got an error reading communication packets)
    100223 21:36:33 [Warning] Aborted connection 43866 to db: 'gases' user: 'root' host: 'localhost' (Got an error reading communication packets)
    100223 21:36:33 [Warning] Aborted connection 43864 to db: 'gases' user: 'root' host: 'localhost' (Got an error reading communication packets)
    打开windows的事件查看器中同样也有错误,错误提示信息如下:事件 ID ( 100 )的描述(在资源( MySQL )中)无法找到。本地计算机可能没有必要的注册信息或消息 DLL 文件来从远程计算机显示消息。您可能可以使用 /AUXSOURCE= 标识来检索词描述;查看帮助和支持以了解详细信息。下列信息是事件的一部分: Aborted connection 45109 to db: 'gases' user: 'root' host: 'localhost' (Got an error reading communication packets)
    打开慢查询日志,信息如下:
    # Time: 100215 18:50:04
    # User@Host: root[root] @ localhost [127.0.0.1]
    # Query_time: 12.328125  Lock_time: 0.000000 Rows_sent: 501  Rows_examined: 1444
    SET timestamp=1266231004;
    select newsitem0_.news_id as news1_27_, newsitem0_.cat_id as cat2_27_, newsitem0_.news_title as news3_27_, newsitem0_.news_author as news4_27_, newsitem0_.news_content as news5_27_, newsitem0_.news_source as news6_27_, newsitem0_.news_date as news7_27_, newsitem0_.checked as checked27_, newsitem0_.pos as pos27_, newsitem0_.editor as editor27_, newsitem0_.auditor as auditor27_, newsitem0_.news_vicetitle as news12_27_, newsitem0_.picture as picture27_, newsitem0_.news_picture as news14_27_, newsitem0_.pictured as pictured27_, newsitem0_.login_name as login16_27_, newsitem0_.news_key as news17_27_, newsitem0_.hits as hits27_ from news_item newsitem0_ where newsitem0_.news_title like '%出厂价格%' or newsitem0_.news_key like '%出厂价格%' order by newsitem0_.news_id Desc;
    # Time: 100215 20:35:02
    # User@Host: root[root] @ localhost [127.0.0.1]
    # Query_time: 4.453125  Lock_time: 0.000000 Rows_sent: 590  Rows_examined: 1782
    SET timestamp=1266237302;
    select newsitem0_.news_id as news1_27_, newsitem0_.cat_id as cat2_27_, newsitem0_.news_title as news3_27_, newsitem0_.news_author as news4_27_, newsitem0_.news_content as news5_27_, newsitem0_.news_source as news6_27_, newsitem0_.news_date as news7_27_, newsitem0_.checked as checked27_, newsitem0_.pos as pos27_, newsitem0_.editor as editor27_, newsitem0_.auditor as auditor27_, newsitem0_.news_vicetitle as news12_27_, newsitem0_.picture as picture27_, newsitem0_.news_picture as news14_27_, newsitem0_.pictured as pictured27_, newsitem0_.login_name as login16_27_, newsitem0_.news_key as news17_27_, newsitem0_.hits as hits27_ from news_item newsitem0_ where newsitem0_.news_title like '%出厂价格%' or newsitem0_.news_key like '%出厂价格%' order by newsitem0_.news_id Desc;
    C:\Program Files\MySQL\MySQL Server 5.1\bin\mysqld, Version: 5.1.43-community-log (MySQL Community Server (GPL)). started with:
    TCP Port: 3306, Named Pipe: (null)我的配置文件参数如下:
    port=3306
    skip-locking
    log_warnings
    query_cache_size=284M
    log-slow-queries =
    long_query_time = 2
    log-error = "C:/Program Files/MySQL/MySQL Server 5.1/logs"
    max_allowed_packet = 264M
    back_log = 900
    max_connect_errors = 800
    wait_timeout = 68800
    interactive_timeout = 68800
    federated
    net_read_timeout=120
    max_connections=1024
    table_cache=500
    open-files-limit=2048我从mysql官方论坛上查询到有两个人对这种问题的回答如下:
    I got rid of these errors by making sure I closed all threads propery before opening new ones. Use the conn# in the error to check the query log to find what parts of your code that does not close threads properly. FYI I was having this error when running a loop breaking a large query up into many smaller queries. When I added a sleep of half a second after each query the problem seemed to mostly go away.但是我仍然找不到问题在哪里。请各位指点,谢谢。
      

  4.   

    那么是程序问题吗?从慢查询日志来看是否是程序需要优化?
    慢查询日志如下:
    打开慢查询日志,信息如下: 
    # Time: 100215 18:50:04 
    # User@Host: root[root] @ localhost [127.0.0.1] 
    # Query_time: 12.328125  Lock_time: 0.000000 Rows_sent: 501  Rows_examined: 1444 
    SET timestamp=1266231004; 
    select newsitem0_.news_id as news1_27_, newsitem0_.cat_id as cat2_27_, newsitem0_.news_title as news3_27_, newsitem0_.news_author as news4_27_, newsitem0_.news_content as news5_27_, newsitem0_.news_source as news6_27_, newsitem0_.news_date as news7_27_, newsitem0_.checked as checked27_, newsitem0_.pos as pos27_, newsitem0_.editor as editor27_, newsitem0_.auditor as auditor27_, newsitem0_.news_vicetitle as news12_27_, newsitem0_.picture as picture27_, newsitem0_.news_picture as news14_27_, newsitem0_.pictured as pictured27_, newsitem0_.login_name as login16_27_, newsitem0_.news_key as news17_27_, newsitem0_.hits as hits27_ from news_item newsitem0_ where newsitem0_.news_title like '%出厂价格%' or newsitem0_.news_key like '%出厂价格%' order by newsitem0_.news_id Desc; 
    # Time: 100215 20:35:02 
    # User@Host: root[root] @ localhost [127.0.0.1] 
    # Query_time: 4.453125  Lock_time: 0.000000 Rows_sent: 590  Rows_examined: 1782 
    SET timestamp=1266237302; 
    select newsitem0_.news_id as news1_27_, newsitem0_.cat_id as cat2_27_, newsitem0_.news_title as news3_27_, newsitem0_.news_author as news4_27_, newsitem0_.news_content as news5_27_, newsitem0_.news_source as news6_27_, newsitem0_.news_date as news7_27_, newsitem0_.checked as checked27_, newsitem0_.pos as pos27_, newsitem0_.editor as editor27_, newsitem0_.auditor as auditor27_, newsitem0_.news_vicetitle as news12_27_, newsitem0_.picture as picture27_, newsitem0_.news_picture as news14_27_, newsitem0_.pictured as pictured27_, newsitem0_.login_name as login16_27_, newsitem0_.news_key as news17_27_, newsitem0_.hits as hits27_ from news_item newsitem0_ where newsitem0_.news_title like '%出厂价格%' or newsitem0_.news_key like '%出厂价格%' order by newsitem0_.news_id Desc; 
    C:\Program Files\MySQL\MySQL Server 5.1\bin\mysqld, Version: 5.1.43-community-log (MySQL Community Server (GPL)). started with: 
    TCP Port: 3306, Named Pipe: (null)