简体   繁体   English

远程连接到我的MySQL数据库的API

[英]API to connect to my MySQL Database Remotely

apparently my hosting provider does not support Remote MySQL Usage as it says in its Knowledge Base even though i bought a premium package 显然,我的托管服务提供商不支持远程MySQL使用,正如我在知识库中所说的那样,即使我购买了高级软件包

remote MySQL connections are disabled for security and performance reasons. You can only connect to MySQL from your PHP scripts hosted on our servers.

is there any way i can make an API so that i can connect to my MySQL Remotely ?. 有什么方法可以使API可以远程连接到MySQL? i need to use the Database in my Host Account as a source of information for my Android Application. 我需要使用主机帐户中的数据库作为Android应用程序的信息源。 thanks 谢谢

You should look into using something like a HTTP Tunnel . 您应该考虑使用HTTP隧道之类的东西。

This post outlines a method of doing this for Android. 这篇文章概述了一种针对Android的方法。

Basically you connect through this tunnel which is placed on your server, and can the communicate with the server as if you were localhost . 基本上,您通过放置在服务器上的此隧道进行连接,并且可以像localhost一样与服务器进行通信。

SSH is also another option, although you'll need remote SSH access enabled by your host. SSH也是另一个选择,尽管您需要主机启用远程SSH访问。 That's normally something you'll have to specifically request for them to enable. 通常,您必须特别要求他们启用它。

You would then create an SSH tunnel using a technique like this and then use that as your connection for your database. 然后,您将使用类似的技术创建SSH隧道,然后将其用作数据库的连接。 Once you've initiated the connection you would then query it as normal. 启动连接后,您将照常查询它。

There are possibilities here. 这里有可能。

  1. Your hosting provider may have allowed access of the database only on certain IP(s) on certain PORTS. 您的主机提供商可能只允许在某些PORTS上的某些IP上访问数据库。 In this case, you cannot access the database even if you write API's because the connection is not open to the IP/PORT through which you are accessing through. 在这种情况下,即使您编写API,也无法访问数据库,因为与您通过其访问的IP / PORT的连接未打开。

  2. The database admin can also block access to certain table(s) or database(s) for certain users. 数据库管理员还可以阻止某些用户访问某些表或数据库。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM