MySQL通过LOCALHOST工作,但通过IP

时间:2017-06-14 06:13:22

标签: php mysql hosting cpanel

在我的虚拟主机上,MySQL通过本地主机连接到它时工作得很好。但是,当我尝试介绍托管的IP时,它只是给了我这个错误:   Connection Refused.当我进入网站时会发生这种情况。   我检查了远程连接和所有这些东西,一切正常。

1 个答案:

答案 0 :(得分:0)

If your hosting is cPanel based and they allow remote MySQL connection, you should make sure that on the server which hosts the databse you have allowed a connection fromn the IP address hosting the website,meaning:

If your website is hosted on IP 11.11.11.1 and your database is hosted on a server with IP 22.22.22.2 you should login to the cPanel of the server 22.22.22.2 and allow Remote mysql connection for the IP 11.11.11.1 . This way the website will be able to connect to the databse successfully.