how can i use mysql with meteor?? and is it a great idea to use mysql with meteor?
You can’t officially. Meteor only supports Mongo database officially at this point in time.
I read and write data into mySQL in production via nodejs. The data is read from mySQL into Mongo and then written back into mySQL when needed…
- Install meteorhacks:npm
- add to packages.json a mySQL mongo package like node-mysql
Then you manage the mysql connection from the server via methods.
At some point we added an throttled observer on the Mongo collections making the backup Mongo => mySQL automatic.
That was a very easy and effective way to integrate the Meteor application with an existing PHP one. We replaced an aging PHP part and synchronized the user login information in such a way the user could login from PHP and be automatically logged in Meteor.
This pluralsight course uses the npm approach to deal with an external DB. In this case it’s postgres, but the general theory stands for any external DB.
Pluralsight is paid, but you can get a limited time trial (beware it’s limited to not very many hours, so choose what you watch carefully).
You can use GraphQL for SQL support. I haven’t tried the mysql drivers myself but it works great with RethinkDB. You’ll need to manually insert the response data into mini-mongo (via local collections) if you’re using Blaze. User accounts will still need to be stored in mongo but the least amount of data you need for that is the user id/password info. User profiles could be stored in a table.