bd96500e110b49cbb3cd949968f18be7.png

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

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

What can be the issue :

my php script

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();

}

?>

解决方案

Maybe this would be

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

Or

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

Logo

瓜分20万奖金 获得内推名额 丰厚实物奖励 易参与易上手

更多推荐