是否可以远程访问共享主机上的mysql数据库? [英] is it possible to remote access to mysql database on shared hostings?
问题描述
我在共享主机上有一个使用MySQL数据库的网站,现在我想在本地应用程序中访问该数据库. 在开始为我的应用程序编写代码之前,我决定使用一些查询生成器应用程序,最后我找到了DBVisualizer和Valentia Studio,但是我无法连接到主机上的数据库. 这些是我所做的事情:
I have a website on a shared hosting that uses a MySQL database , now i want to access the database in my local application . before starting to code for my application i decided to use some query builder applications , finally i found DBVisualizer and Valentia Studio , but i cannot connect to my database on the host . these are the thing that i have done :
1. I got my web site IP by pinging the web site ( i used IP address and host name both for server name )
2. i added the % character in Remote Database Access Hosts .
3. from phpMyAdmin i found 3306 as MySQL port .
但是我仍然无法访问数据库. 我收到超时错误,在使用ping Server时在DBVisualizer中,它没有响应,但是当我将其用于本地Web服务器(连接到MAMP)时,它的响应是"Server is live"
but i still cants access the database . i get time out error , in DBVisualizer when i use ping Server , it doesn't respond , but when i use this for my local web server ( Connecting to MAMP ) it response with "Server is alive"
我怎么知道问题出在哪里,我应该如何解决?
how do i know what is the problem and how should i solve it ?
推荐答案
在大多数默认安装中,MySQL绑定到127.0.0.1-仅允许本地连接.
In most default installations, MySQL binds to 127.0.0.1 - which only allows local connections.
如果您要更改此设置(注意:这可能是一个安全问题),则需要在配置文件中更改它(通常在Linux发行版中为/etc/mysql/my.cnf
).
或在Windows中,它可能位于以下位置:
If you wish to change that (ATTENTION: it might be a security issue), you need to change it in the configuration file (usually /etc/mysql/my.cnf
in linux distributions).
Or in windows it might be on these locations:
C:\Windows\my.ini C:\Windows\my.cnf C:\my.ini C:\my.cnf
C:\Program Files\MySQL\MySQL Server 5.5\my.ini
C:\Program Files\MySQL\MySQL Server 5.5\my.cnf
通常这样注释掉bind-address
行就足够了,这将允许来自所有IP的连接:
Usually it's enough to comment out the bind-address
line like this, which will allow connections from all IPs:
# bind-address = 127.0.0.1
还值得注意的是,大多数网站托管者都不允许来自任意主机的MySQL连接,并且您无法更改这一事实(您只能通过使用本地应用程序来访问MySQL实例-在大多数情况下为phpmyadmin).
It is also worth noting that most webhosters won't allow MySQL connections from arbitrary hosts and you can't change that fact (you may only access your MySQL instance by using a local application - in most cases phpmyadmin).
这篇关于是否可以远程访问共享主机上的mysql数据库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!