今天在测试一数据处理功能发现连接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 ( )
程序代码很简单,代码如下:
- $sql = "Select * from v_xyp where systype=5 ";
- $array = array();
- $rq = mysql_query( $sql );
- if( mysql_num_rows( $rq ) )
- {
- while( $rs = mysql_fetch_array( $rq ) )
- {
- //$sql ="update v_xyp set b_body= '".str_replace("'",'',strip_tags(stripslashes($rs['U_love'])))."' where id=".$rs['id'];
- //mysql_query( $sql ) ;//or die(mysql_error());
- //echo $rs['id'].'<br />';
- $sqlb ="select * from v_xyp where systype=5 and b_body='".str_replace("'",'',strip_tags(stripslashes($rs['U_love'])))."' and id<>".$rs['id'];
- $query = mysql_query( $sqlb ) ;//or die(mysql_error());
- $num = mysql_num_rows( $query );
- if( $num )//开源代码Vevb.com
- {
- echo '<font color="#0000FF">{'.$rs['title'].'}重复内容有{'.$num.'}条</font><br />';
- while( $rs1 = mysql_fetch_array( $query ) )
- {
- echo $rs1['title'].'<br />';
- }
- echo '<hr />';
- }/**/
- }
- //echo '标题:<font color=red>'.$title.'</font>己处理过,自动跳过!';
- }
解决办法:想来想去都没想到,后来在服务中看mysql状态结果自动挂了,mysql自动停了,这个可能与我数据处理量或算法有问题了,重启mysql就解决了.
新闻热点
疑难解答