Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to access server MySQL database from iOS app

I'm trying to write an iOS app using Xcode.

A simple login prompting username and password.

I have no idea how to open a database connection to validate the username and password.

The database I use is mysql.

I tried using this link http://macbug.org/macosxsample/mysql#.Ur8AYBbtGPF

but I get an error when I tried to add libmysqlclient.a to the frameworks and library.

like image 238
user3142046 Avatar asked Mar 23 '26 15:03

user3142046


1 Answers

If your database is on a server somewhere, then you would generally not have your iOS app interact directly with the database server, but rather you would write a web service that the app would interact with (via NSURLConnection, NSURLSession or something like AFNetworking), and the web service would interact with the MySQL database.

In terms of how to write a web service, often, when people are writing their first web service, they'll use some simple technology like PHP. Do you know what options you have on your server? If PHP is an option, then you can check out Ray Wenderlich's How to Write a Simple PHP/MySQL Web Service. Then check out How to Write an iOS App that Uses a Web Service.

like image 103
Rob Avatar answered Mar 25 '26 04:03

Rob



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!