# Connect ionic app to mysql database

**URL:** <https://forum.ionicframework.com/t/connect-ionic-app-to-mysql-database/54684>\
**Category:** ionic-v1\
**Created:** [June 13, 2016, 2:27pm UTC](https://forum.ionicframework.com/t/connect-ionic-app-to-mysql-database/54684 "2016-06-13T14:27:34Z")\
**Posts on this page:** 20\
**Page:** 2

<div class="post-metadata">

**Author:** ![Bonsaiko](https://avatars.discourse-cdn.com/v4/letter/b/a698b9/32.png) [@Bonsaiko](https://forum.ionicframework.com/u/Bonsaiko)\
**Post date:** [June 15, 2016, 8:11pm UTC](https://forum.ionicframework.com/t/connect-ionic-app-to-mysql-database/54684/21 "2016-06-15T20:11:29Z")

</div>

I want the credentials to be used during the use of the app by the user.  
But the users have to be stored in a database on my server, and not locally.  
How is it usually handled?  
What would be the best practice?

---

<div class="post-metadata">

**Author:** ![rapropos](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/rapropos/32/100227_2.png) [@rapropos](https://forum.ionicframework.com/u/rapropos)\
**Post date:** [June 15, 2016, 8:16pm UTC](https://forum.ionicframework.com/t/connect-ionic-app-to-mysql-database/54684/22 "2016-06-15T20:16:25Z")

</div>

> [@Bonsaiko](#):
>
> I want the credentials to be used during the use of the app by the user.

Then you’ll want localstorage, which is less persistent. As for what the credentials actually look like, there are several options. If you want to let people sign in using Facebook or Google or Twitter or whatnot, look into OAuth. For standalone solutions, I prefer JWT.

---

<div class="post-metadata">

**Author:** ![Bonsaiko](https://avatars.discourse-cdn.com/v4/letter/b/a698b9/32.png) [@Bonsaiko](https://forum.ionicframework.com/u/Bonsaiko)\
**Post date:** [June 15, 2016, 8:36pm UTC](https://forum.ionicframework.com/t/connect-ionic-app-to-mysql-database/54684/23 "2016-06-15T20:36:52Z")

</div>

JWT? What is it ?  
What if I’d like tto offer several connexion options ?  
For example, standard connexion with email/ password, or the ability to login with facebook credentials.

---

<div class="post-metadata">

**Author:** ![Nik\_eu](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/nik_eu/32/100533_2.png) [@Nik\_eu](https://forum.ionicframework.com/u/Nik_eu)\
**Post date:** [June 15, 2016, 10:45pm UTC](https://forum.ionicframework.com/t/connect-ionic-app-to-mysql-database/54684/24 "2016-06-15T22:45:01Z")

</div>

You should use tokens…

---

<div class="post-metadata">

**Author:** ![Bonsaiko](https://avatars.discourse-cdn.com/v4/letter/b/a698b9/32.png) [@Bonsaiko](https://forum.ionicframework.com/u/Bonsaiko)\
**Post date:** [June 15, 2016, 10:50pm UTC](https://forum.ionicframework.com/t/connect-ionic-app-to-mysql-database/54684/25 "2016-06-15T22:50:12Z")

</div>

tokens, ok, but how?  
I followed a course on ionic, the teacher showed how to do this and he used tokens, but he was using a node.js server. I’m using apache server witth mysql database. So I don’t know how to do…

---

<div class="post-metadata">

**Author:** ![Nik\_eu](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/nik_eu/32/100533_2.png) [@Nik\_eu](https://forum.ionicframework.com/u/Nik_eu)\
**Post date:** [June 15, 2016, 11:13pm UTC](https://forum.ionicframework.com/t/connect-ionic-app-to-mysql-database/54684/26 "2016-06-15T23:13:54Z")

</div>

Maybe this article will be interesteing to you?

> **[Token-Based Authentication for AngularJS and Laravel Apps](https://scotch.io/tutorials/token-based-authentication-for-angularjs-and-laravel-apps)**
>
> Adding authentication to an AngularJS and Laravel application is not the most straight-forward, especially if we take the approach of creating independent front-end and backend applications and connecting them with an API exposed by Laravel. Laravel...

---

<div class="post-metadata">

**Author:** ![Bonsaiko](https://avatars.discourse-cdn.com/v4/letter/b/a698b9/32.png) [@Bonsaiko](https://forum.ionicframework.com/u/Bonsaiko)\
**Post date:** [June 20, 2016, 12:09pm UTC](https://forum.ionicframework.com/t/connect-ionic-app-to-mysql-database/54684/27 "2016-06-20T12:09:58Z")

</div>

Thank you all for your answers, things are clearer for me now.

---

<div class="post-metadata">

**Author:** ![anicacute09](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/anicacute09/32/113162_2.png) [@anicacute09](https://forum.ionicframework.com/u/anicacute09)\
**Post date:** [July 13, 2016, 4:05am UTC](https://forum.ionicframework.com/t/connect-ionic-app-to-mysql-database/54684/28 "2016-07-13T04:05:24Z")

</div>

Hi @Bonsaiko I would like to see also your codes, can you send me also. Here is my email [aljun.bellen12@gmail.com](mailto:aljun.bellen12@gmail.com). I manage to create RESTful API using Slim Framework too, but my problem now is how to connect my app to the rest i made… like a login. Thanks in advance

---

<div class="post-metadata">

**Author:** ![Bonsaiko](https://avatars.discourse-cdn.com/v4/letter/b/a698b9/32.png) [@Bonsaiko](https://forum.ionicframework.com/u/Bonsaiko)\
**Post date:** [July 20, 2016, 8:50am UTC](https://forum.ionicframework.com/t/connect-ionic-app-to-mysql-database/54684/29 "2016-07-20T08:50:27Z")

</div>

Hello Anicacute09. I’m going to send you my code by mail.

---

<div class="post-metadata">

**Author:** ![anicacute09](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/anicacute09/32/113162_2.png) [@anicacute09](https://forum.ionicframework.com/u/anicacute09)\
**Post date:** [July 20, 2016, 5:12pm UTC](https://forum.ionicframework.com/t/connect-ionic-app-to-mysql-database/54684/30 "2016-07-20T17:12:45Z")

</div>

yah thanks for that… I am really glad for your help…

---

<div class="post-metadata">

**Author:** ![tenison201](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/tenison201/32/134008_2.png) [@tenison201](https://forum.ionicframework.com/u/tenison201)\
**Post date:** [August 2, 2016, 10:06pm UTC](https://forum.ionicframework.com/t/connect-ionic-app-to-mysql-database/54684/31 "2016-08-02T22:06:37Z")

</div>

hey…l have been following yur discussions…hav similar problems conecting my app to mysql…can you send me yur code [tooo...tenisonoseiowusu@gmail.com](mailto:tooo...tenisonoseiowusu@gmail.com)  
thanks

---

<div class="post-metadata">

**Author:** ![tenison201](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/tenison201/32/134008_2.png) [@tenison201](https://forum.ionicframework.com/u/tenison201)\
**Post date:** [August 2, 2016, 10:09pm UTC](https://forum.ionicframework.com/t/connect-ionic-app-to-mysql-database/54684/32 "2016-08-02T22:09:35Z")

</div>

hey…l have been following yur discussions…hav similar problems  
conecting my app to mysql…can you send me yur code  
[tooo...tenisonoseiowusu@gmail.com](mailto:tooo...tenisonoseiowusu@gmail.com)  
thanks

---

<div class="post-metadata">

**Author:** ![edgareisma](https://avatars.discourse-cdn.com/v4/letter/e/a698b9/32.png) [@edgareisma](https://forum.ionicframework.com/u/edgareisma)\
**Post date:** [August 10, 2016, 1:22pm UTC](https://forum.ionicframework.com/t/connect-ionic-app-to-mysql-database/54684/33 "2016-08-10T13:22:32Z")

</div>

Hi @Bonsaiko I am new to Ionic also and I would like to know how to connect my ionic app to my own database and server. I would like to see your codes on that specific matter, can you please send me your codes on my email: [edgareisma@yahoo.com.ph](mailto:edgareisma@yahoo.com.ph) or [edgar.eisma@gmail.com](mailto:edgar.eisma@gmail.com). Hoping for your response 🙂 Thank you 🙂

---

<div class="post-metadata">

**Author:** ![fh\_vCillusion](https://avatars.discourse-cdn.com/v4/letter/f/a698b9/32.png) [@fh\_vCillusion](https://forum.ionicframework.com/u/fh_vCillusion)\
**Post date:** [October 15, 2016, 5:04pm UTC](https://forum.ionicframework.com/t/connect-ionic-app-to-mysql-database/54684/34 "2016-10-15T17:04:47Z")

</div>

hi @Bonsaiko l have been following yur discussions…have similar problems conecting my app to mysql…can you send me yur code too…  
[flaskhooks@gmail.com](mailto:flaskhooks@gmail.com)  
thanks

---

<div class="post-metadata">

**Author:** ![tenison201](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/tenison201/32/134008_2.png) [@tenison201](https://forum.ionicframework.com/u/tenison201)\
**Post date:** [October 25, 2016, 9:55pm UTC](https://forum.ionicframework.com/t/connect-ionic-app-to-mysql-database/54684/35 "2016-10-25T21:55:38Z")

</div>

@Bonsaiko [http://forum.ionicframework.com/users/bonsaiko](http://forum.ionicframework.com/users/bonsaiko) please can you  
send me copy of that code… working on similar project…thank you(  
[tenisonoseiowusu@gmail.com](mailto:tenisonoseiowusu@gmail.com))

---

<div class="post-metadata">

**Author:** ![zdrava](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/zdrava/32/106234_2.png) [@zdrava](https://forum.ionicframework.com/u/zdrava)\
**Post date:** [January 20, 2017, 11:55am UTC](https://forum.ionicframework.com/t/connect-ionic-app-to-mysql-database/54684/36 "2017-01-20T11:55:10Z")

</div>

Hello, I am also new at Ionic, and I need to connect ionic app to mysql database as you did.  
Is it possible that you send me your code by mail: [zdrava\_mo@hotmail.com](mailto:zdrava_mo@hotmail.com) ?  
Thanks in advance.

---

<div class="post-metadata">

**Author:** ![smessie](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/smessie/32/106444_2.png) [@smessie](https://forum.ionicframework.com/u/smessie)\
**Post date:** [January 29, 2017, 10:15am UTC](https://forum.ionicframework.com/t/connect-ionic-app-to-mysql-database/54684/37 "2017-01-29T10:15:44Z")

</div>

Hi @Bonsaiko and @anicacute09  
Could you send me the code to my email?  
smessiecraft[at][outlook.com](http://outlook.com)  
It would Really help me because I have the same problem.

Thank you in advance

---

<div class="post-metadata">

**Author:** ![jeevaarumugam](https://avatars.discourse-cdn.com/v4/letter/j/9de0a6/32.png) [@jeevaarumugam](https://forum.ionicframework.com/u/jeevaarumugam)\
**Post date:** [February 8, 2017, 6:31am UTC](https://forum.ionicframework.com/t/connect-ionic-app-to-mysql-database/54684/38 "2017-02-08T06:31:58Z")

</div>

> [@smessie](#):
>
> Hi @Bonsaiko and @anicacute09Could you send me the code to my email?

Hi @Bonsaiko and @anicacute09  
Could you send me the code to my email?  
my mail [id:jeevamtechit@gmail.com](mailto:id:jeevamtechit@gmail.com)

---

<div class="post-metadata">

**Author:** ![anicacute09](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/anicacute09/32/113162_2.png) [@anicacute09](https://forum.ionicframework.com/u/anicacute09)\
**Post date:** [February 8, 2017, 6:35am UTC](https://forum.ionicframework.com/t/connect-ionic-app-to-mysql-database/54684/39 "2017-02-08T06:35:01Z")

</div>

You can search about Rest API using any frameworks like Laravel, CodeIgniter and the one I use is Slim for creating RESTful api… And just use HTTP Request by angular to communicate from server to you app or vice versa…

Useful Links:

> **[PHP Restful API Framework SLIM to Create REST API Part 1](https://www.simplifiedcoding.net/php-restful-api-framework-slim-tutorial-1/)**
>
> Create REST API using PHP Restful API Framework SLIM. In this post we will learn to create PHP Restful API Framework SLIM to create our web services

> **[How to create REST API for Android app using PHP, Slim and MySQL - Day 1/2](http://www.androidhive.info/2014/01/how-to-create-rest-api-for-android-app-using-php-slim-and-mysql-day-12-2/)**
>
> Tutorial about creating a simple REST Api for mobile applications using PHP, MySQL and Slim framework. An of example of android task manager application is demonstrated.

---

<div class="post-metadata">

**Author:** ![jeevaarumugam](https://avatars.discourse-cdn.com/v4/letter/j/9de0a6/32.png) [@jeevaarumugam](https://forum.ionicframework.com/u/jeevaarumugam)\
**Post date:** [February 8, 2017, 6:47am UTC](https://forum.ionicframework.com/t/connect-ionic-app-to-mysql-database/54684/40 "2017-02-08T06:47:13Z")

</div>

thank u so much @anicacute09.

[Previous page](https://forum.ionicframework.com/t/connect-ionic-app-to-mysql-database/54684.md?page=1)

[Next page](https://forum.ionicframework.com/t/connect-ionic-app-to-mysql-database/54684.md?page=3)
