mysqli_connect(): (HY000/2002): Connection timed out on hosting

后端 未结 4 1841
我寻月下人不归
我寻月下人不归 2020-12-21 12:41

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): Co

4条回答
  •  南笙
    南笙 (楼主)
    2020-12-21 13:04

    If your website and MySQL database are hosted on separate servers, make sure that you've mentioned correct MySQL hostname (resolvable) in connection string.

    In case you've specified the correct username, most probably your MySQL server isn't allowing remote MySQL connections from web server where you site resides. Contact your web hosting provider for the exact MySQL hostname and to allow your web server IP address for remote MySQL connections.

提交回复
热议问题