简体   繁体   English

C ++应用程序如何在不使MySQL服务器接受远程连接的情况下访问远程MySQL数据库?

[英]How can C++ applications access a remote MySQL database without making MySQL server accept remote connections?

I'm looking for an effective approach for this problem: 我正在寻找解决此问题的有效方法:

Server: 服务器:

  • Webinterface, User can use forms. Web界面,用户可以使用表格。
  • The Data entered in the forms is getting saved in a database. 在表单中输入的数据将被保存在数据库中。

Several clients: 几个客户:

  • A client program written in c++ can access database. 用c ++编写的客户端程序可以访问数据库。

When I use a normal MySQL DB I would have to open the whole MySQLServer to accept remote connections, which I would like to avoid. 当我使用普通的MySQL数据库时,我必须打开整个MySQLServer以接受远程连接,这是我想避免的。

I found several MySQL APIs, but no alternative for my problem. 我找到了几个MySQL API,但是我的问题别无选择。 An 'webdatabase <-> remote c++ client' solution. “ Webdatabase <->远程C ++客户端”解决方案。

Will I have to write my own server which will parse the DB info to the client? 我是否需要编写自己的服务器来将数据库信息解析到客户端? :/ :/

Hope there is an easier solution! 希望有一个更简单的解决方案!

What you will want to do is write an API that runs on the same webinterface to which you can programatically talk. 您需要做的是编写一个可以在与您进行编程交谈的相同Web界面上运行的API。 You can look at SOAP for example, or a REST based service, or simply JSON. 例如,您可以查看SOAP,或基于REST的服务,或仅查看JSON。

This will allow your C++ client to "connect" to the database on the server side through a controlled channel so that you are not opening up MySQL to access from the outside. 这将允许您的C ++客户端通过受控通道“连接”到服务器端的数据库,这样就不会打开MySQL来从外部进行访问。

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

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