如何在全球范围内使数据库可访问 [英] How to make Database Accessible worldwide

查看:91
本文介绍了如何在全球范围内使数据库可访问的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个项目,我的数据库要保持全局,即我的应用程序可以远程访问它。那么我可以通过多少方式实现这一目标?是否可以在一台机器上安装MySQL并为该机器提供静态IP并提供该应用程序的链接?请帮助......

I am developing a project whose database I want to keep global, i.e. my application can access it remotely. So how many ways can I achieve that? Is it possible if I install MySQL in one machine and provide a static IP to that machine and provide that link to my application? Please help...

推荐答案

首先请遵循Prasad Khandekar的建议。



其次如果你想从外界访问mysql,你需要两件事。



1。可从外界访问的服务器

2.用户帐户已正确配置为可从外界访问。



约2:
如果您使用IP在本地计算机上连接,请说
。 192.1681.1.100



现在你要创建一个用户名user1,其中有一些权限可以通过ip 192.168.1.100与你的机器连接





因此您必须创建一个名为 user1 且主机为192.168.1.100的用户,然后才能创建用户访问192.168.1.100将能够与您的服务器连接。



现在,假设您有一台机器,在本地和外部世界拥有IP 192.168.1.100可以使用这个ip 173.194.38.95访问这台机器(实际上这个ip响应来自google.co.jp)。所以,当你本地网外的人想要使用这个mysql时,他们必须要求:



First of all follow the suggestion of Prasad Khandekar.

Secondly if you want to access mysql from outside world you would need two thing.

1. Server which is accessible from outside world
2. User account properly configured to access from outside world.

about 2:
say if you are connected in your local machine with IP. 192.1681.1.100

now you want to create a user name user1 with some privileges who will be able to connect with your machine with the ip 192.168.1.100


so you will have to create a user with name user1 and host "192.168.1.100", then user who can access 192.168.1.100 will be able to connect with your server.

Now, say you have a machine, who has IP 192.168.1.100 in local and out-side world can access this machine using this ip 173.194.38.95(actually this ip response is from google.co.jp). So when people from outside your local net will want to use this mysql then they will have to request:

#mysql -h 173.194.38.95 -u user1 -p





但服务器将拒绝该请求。导致user1仅响应主机192.168.1.100,在这种情况下,您将不得不创建另一个用户名user1与主机173.194.38.95



现在,如果你不在乎关于主持人问题。然后只需将主机设置为'%'即可覆盖所有内容(应该是我的第一行)



But server will deny that request. Cause user1 only response for host 192.168.1.100, in this case you will have to create another user name user1 with host 173.194.38.95

Now if you don't care about the host issue. then just set the host to '%' that will cover everything(It should be my first line)


这篇关于如何在全球范围内使数据库可访问的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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