A-A+

Warning:mysql_connect() [function.mysql-connect]: [2002] 由于目标机器.

2017年10月18日 PHP技术文章 暂无评论 阅读 0 views 次

今天在测试一数据处理功能发现连接mysql时突然碰到Warning: mysql_connect() [function.mysql-connect]:[2002] 由于目标机器积极拒绝,无法连接提示了,下面我们一起来看问题解决方法.

错误代码如下:

aabb Warning: mysql_connect() [function.mysql-connect]: [2002] 由于目标机器积极拒绝,无法连接.(trying to connect via tcp://localhost:3306) in X:test7.php on line 6

Warning: mysql_connect() [function.mysql-connect]: 由于目标机器积极拒绝,无法连接。 in X:test7.php on line 6

Warning: mysql_select_db() [function.mysql-select-db]: [2002] 由于目标机器积极拒绝,无法连接。 (trying to connect via tcp://localhost:3306) in X:test7.php on line 7

Warning: mysql_select_db() [function.mysql-select-db]: 由于目标机器积极拒绝,无法连接。 in X:test7.php on line 7

Warning: mysql_select_db() [function.mysql-select-db]: A link to the server could not be established in X:test7.php on line 7

Warning: mysql_query() [function.mysql-query]: [2002] 由于目标机器积极拒绝,无法连接。 (trying to connect via tcp://localhost:3306) in X:test7.php on line 8

Warning: mysql_query() [function.mysql-query]: 由于目标机器积极拒绝,无法连接。 in X:test7.php on line 8

Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in X:test7.php on line 8

Warning: mysql_query() [function.mysql-query]: [2002] 由于目标机器积极拒绝,无法连接。 (trying to connect via tcp://localhost:3306) in X:test7.php on line 14

Warning: mysql_query() [function.mysql-query]: 由于目标机器积极拒绝,无法连接。 in X:test7.php on line 14

Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in X:test7.php on line 14

Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in X:test7.php on line 15
Array ( )

程序代码很简单,代码如下:

  1. $sql = "Select * from v_xyp where systype=5 ";   
  2. $array = array();   
  3. $rq = mysql_query( $sql );   
  4. if( mysql_num_rows( $rq ) )   
  5. {   
  6.  while$rs = mysql_fetch_array( $rq ) )   
  7.  {   
  8.      
  9.   //$sql ="update v_xyp set b_body= '".str_replace("'",'',strip_tags(stripslashes($rs['U_love'])))."' where id=".$rs['id'];   
  10.   //mysql_query( $sql ) ;//or die(mysql_error());   
  11.   //echo $rs['id'].'<br />';   
  12.   $sqlb ="select * from v_xyp where systype=5 and  b_body='".str_replace("'",'',strip_tags(stripslashes($rs['U_love'])))."' and id<>".$rs['id'];   
  13.   $query = mysql_query( $sqlb ) ;//or die(mysql_error());   
  14.   $num = mysql_num_rows( $query );   
  15.   if$num )//开源代码www.xiariboke.net   
  16.   {   
  17.    echo '<font color="#0000FF">{'.$rs['title'].'}重复内容有{'.$num.'}条</font><br />';   
  18.    while$rs1 = mysql_fetch_array( $query ) )   
  19.    {   
  20.     echo  $rs1['title'].'<br />';   
  21.    }   
  22.    echo '<hr />';   
  23.   }/**/   
  24.  }   
  25.  //echo '标题:<font color=red>'.$title.'</font>己处理过,自动跳过!';   
  26. }   

解决办法:想来想去都没想到,后来在服务中看mysql状态结果自动挂了,mysql自动停了,这个可能与我数据处理量或算法有问题了,重启mysql就解决了.

标签:

给我留言