MySQL在多台主机上重复拒绝

时间:2012-10-04 07:38:13

标签: php mysql localhost denial-of-service

我已经尝试了我能想到的一切......从我的本地主机转到另一台服务器主机(由于我在他们的服务器上显然使用了ftp,它也使用了localhost),我仍然一直收到错误: 警告:mysqli :: mysqli()[mysqli.mysqli] :( 28000/1045):在/www/zxq.net/中拒绝用户'(审查)_zxq'@'192.168.1.1'(使用密码:YES)第6行的a / p / p /(审查)/htdocs/lib.php 连接失败:访问被拒绝用户'(审查)_zxq'@'192.168.1.1'(使用密码:是)

我已经尝试了多个支持mysql的主机...我一直收到错误,我知道我的凭据是正确的。我已经为数据库以及用户授予了权限。有什么建议? (ps。我向我审查了重要信息)

<?php
$server = 'localhost';
$login = '792981_kputts';
$password = 'whatup4u';
$database = '(censored)_zxq_ireport';

//access
$connection = new mysqli($server, $login, $password, $database);

//executes a given sql query with the params and returns an array as result
function query() {
    global $link;
    $debug = false;

    //get the sql query
    $args = func_get_args();
    $sql = array_shift($args);

    //secure the input
    for ($i=0;$i<count($args);$i++) {
        $args[$i] = urldecode($args[$i]);
        $args[$i] = mysqli_real_escape_string($link, $args[$i]);
    }

    //build the final query
    $sql = vsprintf($sql, $args);

    if ($debug) print $sql;

    //execute and fetch the results
    $result = mysqli_query($link, $sql);
    if (mysqli_errno($link)==0 && $result) {

        $rows = array();

        if ($result!==true)
        while ($d = mysqli_fetch_assoc($result)) {
            array_push($rows,$d);
        }

        //return json
        return array('result'=>$rows);

    } else {

        //error
        return array('error'=>'Database error');
    }
}

//loads up the source image, resizes it and saves with -thumb in the file name
function thumb($srcFile, $sideInPx) {

  $image = imagecreatefromjpeg($srcFile);
  $width = imagesx($image);
  $height = imagesy($image);

  $thumb = imagecreatetruecolor($sideInPx, $sideInPx);

  imagecopyresized($thumb,$image,0,0,0,0,$sideInPx,$sideInPx,$width,$height);

  imagejpeg($thumb, str_replace(".jpg","-thumb.jpg",$srcFile), 85);

  imagedestroy($thumb);
  imagedestroy($image);
}

?>

1 个答案:

答案 0 :(得分:0)

您的错误消息表明您没有从 localhost (127.0.0.1)进行连接,而是建立远程连接(* user'(已发送)_zxq'@'192.168.1.1'*)

进行远程连接时,请确保:

  • 所有防火墙(客户端和服务器)都打开了端口3306
  • 通过将my.cnf中的绑定地址更改为0.0.0.0
  • ,为远程连接配置了mysql
  • 远程用户连接具有连接权限。

即使192.168.1.1是来自服务器的IP,它仍然被认为是远程连接,并且必须执行步骤2和3(有时也是1)。