简体   繁体   中英

How to connect to remote mysql from iphone application?

i am newbie to iphone programming. I am working on an iphone project.

My question is:

How to connect my iphone application to a remote server mysql database directly? There are many ways to connect through PHP scrip/ json/xml/ webservices. But i dont need that. I would like to have direct connetion to mysql of remote server without any intermediate?

Basically you would need to build a mysql client lib for iOS and then use that from Objective-C. This blog post should get you started. As stated by peko you should really reconsider that you are doing the right thing. The mysql network protocol isn't exactly made for mobile clients where connections can drop, be unavailable, etc.

您不应该这样做,因为有人可能会嗅探流量并获取数据库的用户名和密码,或者注入sql代码。

Here's a MySql objective-C client for iPhone. It was traditionally available only for OSX but they just released it for iOS:

http://www.karlkraft.com/index.php/2010/09/17/mysql-for-iphone-and-osx/

I haven't used it. I would still strongly recommend exposing via services. I would also be interested in why you need to directly connect to the DB and why services isn't appropriate :)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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