mysqli_connect():(HY000/2002):连接在主机上超时 [英] mysqli_connect(): (HY000/2002): Connection timed out on hosting

查看:209
本文介绍了mysqli_connect():(HY000/2002):连接在主机上超时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用php连接mysql数据库.但是它在本地计算机上运行良好,但是在联机托管时却不能运行,并且错误显示为 mysqli_connect():(HY000/2002):连接超时

I am trying to connect mysql database using php. But it is running fine on local machine but not when hosted online and error appeared as mysqli_connect(): (HY000/2002): Connection timed out

<?php

$link = mysqli_connect('sql6.freesqldatabase.com','user_name','password','database_name');
if(mysqli_connect_error())
    die("couldn't connect to database");
?>

推荐答案

您的MySQL服务器可能未配置为接受来自您要从中访问它的主机的请求.

Your MySQL server is probably not configured to accept requests from the host you're trying to access it from.

检查服务器的配置. 既然您说本地计算机可以访问它,请检查您允许它的位置,并对联机主机的IP进行相同的操作.

Check the configuration for the server. Since you say the local machine can access it check where you permitted this and do the same for the ip of the online host.

这篇关于mysqli_connect():(HY000/2002):连接在主机上超时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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