MySQL错误:mysqli_connect():(HY000/2002):连接被拒绝 [英] Mysql error : mysqli_connect(): (HY000/2002): Connection refused

查看:2547
本文介绍了MySQL错误:mysqli_connect():(HY000/2002):连接被拒绝的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在数字海洋上安装了mysql并尝试通过php脚本进行连接,但出现此错误

I have install mysql on digital ocean and trying to connect through php script and I got this error

mysqli_connect():(HY000/2002):连接被拒绝 第9行的/var/www/waev.in/signup/ajax/send_code.php无法连接 到MySQL:连接被拒绝

mysqli_connect(): (HY000/2002): Connection refused in /var/www/waev.in/signup/ajax/send_code.php on line 9 Failed to connect to MySQL: Connection refused

可能是什么问题:

我的PHP脚本

<?php
    include '../func/sms_function.php';

    $mysql_host='{ip}';
    $mysql_user='root';
    $mysql_pass='********';
    $my_db='wesearch_waev_user';

    $con = mysqli_connect($mysql_host,$mysql_user,$mysql_pass);

    if (mysqli_connect_errno())
    {
        echo "Failed to connect to MySQL: " . mysqli_connect_error();
    }
?>

推荐答案

也许是

  $mysql_host="localhost";// for local server

 $mysql_host="$ip";// if database is in remote and IP is stored in $ip

这篇关于MySQL错误:mysqli_connect():(HY000/2002):连接被拒绝的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆