mysql_ping faultdoc:
Return Values 
Zero if the connection to the server is alive. Non-zero if an error occurred. A non-zero return does not indicate whether the MySQL server itself is down; the connection might be broken for other reasons such as network problems. 
Q1: after mysql_init(NULL), then use mysql_ping,it would make a seg fault.Q2: do mysql_close(), then use mysql_ping,it alse makes a seg fault.Q3:上面是我总结的2种情形,请问还有哪些情形可能导致segFault?

解决方案 »

  1.   

    另外mysql_ping在本地程序连接到远程的数据库服务器时,也会导致segment?
    为什么?我的猜测原因是:
    Unix平台上的MySQL客户端能够以两种不同的方式连接到mysqld服务器:通过文件系统中的文件(默认为/tmp/mysql.sock)使用Unix套接字进行连接,或通过端口号使用TCP/IP进行连接。Unix套接字文件的连接速度比TCP/IP快,但仅能在与相同计算机上的服务器相连时使用。如果未指定指定主机名或指定了特殊的主机名localhost,将使用Unix套接字。Question 1: Why does "localhost" work but "127.0.0.1 (the loopback
    interface) or IP address etc not work?? NULL also works so I assume it
    has something to do with the differences between a UNIX socket and
    TCP/IP connection. Is there a way to verify??(就是tcp/ip与unix使用
    会导致哪些不同的差异?) 网络延迟时间这方面就不算了。
      

  2.   

    mysql旧版本本身不是很完美,升级到最新mysql5.1,旧问题不会重现了
      

  3.   

    mysql旧版本本身不是很完美,升级到最新mysql5.1,旧问题不会重现了
    确实,我原来用的4.1版本,后来升级到5.1,这些问题都没有了。
    很可能是数据库的问题。