不允许主机连接到此 MySQL 服务器以用于客户端 - 服务器应用程序 [英] Host is not allowed to connect to this MySQL server for client-server application
问题描述
我刚刚将我的表格从一个网络主机导出到另一个 (AWS).认为一切都会顺利(是的),好吧,一切可能出错的地方都出错了.
I just exported my tables from one web host to another (AWS). Thinking everything would go smoothly (yeah right), well, everything that can go wrong has gone wrong.
在尝试查询我的数据库时出现此错误(我以前没有遇到过):
I get this error when trying to query my database (which I didn't get before):
SQLSTATE[HY000] [1130] Host '
这与这篇文章中的错误相同:
This is the same error from this post:
主机'xxx.xx.xxx.xxx' 不允许连接到这个 MySQL 服务器
该帖子中的解决方案似乎围绕着拥有一个管理用户.我正在开发一个聊天应用程序,所以每个用户都需要访问服务器(所以我确信给他们所有的管理权限是一个坏主意).Pascal 在该链接中的回答是:如果您将 mysql 用于客户端/服务器应用程序,则更喜欢子网地址.
但老实说,我不明白他的意思.而且由于解决方案数量众多,根据我的情况,我不确定应该遵循哪一个.
The solution in that post seems to revolve around having an administrative user. I am developing a chat application so every user needs to access the server (so I'm sure it's a bad idea to give them all administrative privileges).
The answer by Pascal in that link says, If you are using mysql for a client/server application, prefer a subnet address.
but I honestly don't understand what he means by that. And because of the amount of solutions, I'm not exactly sure which one I should follow based on my case.
我该如何解决这个问题?
How do I resolve this?
推荐答案
MySQL 具有安全表,用于确定允许谁连接以及从哪个主机 IP 地址进行连接.
MySQL has security tables that determine who is allowed to connect and from what host IP address.
这是一篇关于如何做到这一点的好文章:
Here's a good article on how to do it:
http://www.cyberciti.biz/tips/how-do-i-enable-remote-access-to-mysql-database-server.html
如果您有很多连接,请考虑设置一个服务器来接受连接并与 sql 服务器对话.最简单的方法是设置 REST 接口并使用 Web 服务器.Web 服务器通常也经过高度优化并且相对没有错误.
If you have a lot of connections, consider setting up a server to accept the connections and talk to the sql server. The easiest approach to this is to set up a REST interface and use a web server. Web servers are usually also highly optimized and relatively bug free.
在 AWS 上的类似架构中,我愉快地使用 nginx.
In a similar architecture on AWS, I use nginx happily.
这篇关于不允许主机连接到此 MySQL 服务器以用于客户端 - 服务器应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!