2013-10-03 21:50:38 +00:00
## loopback-connector-mysql
2012-12-14 14:01:44 +00:00
2014-01-10 00:40:11 +00:00
`loopback-connector-mysql` is the MySQL connector module for [loopback-datasource-juggler ](https://github.com/strongloop/loopback-datasource-juggler/ ).
2014-06-24 23:20:19 +00:00
For complete documentation, see [StrongLoop Documentation | MySQL Connector ](http://docs.strongloop.com/display/LB/MySQL+connector ).
2012-12-14 14:01:44 +00:00
2013-10-28 22:12:20 +00:00
## Installation
````sh
npm install loopback-connector-mysql --save
````
2014-01-10 00:40:11 +00:00
## Basic use
2012-12-14 14:01:44 +00:00
2013-07-30 21:21:10 +00:00
To use it you need `loopback-datasource-juggler` .
2012-12-14 14:01:44 +00:00
1. Setup dependencies in `package.json` :
```json
{
...
"dependencies": {
2013-07-30 21:21:10 +00:00
"loopback-datasource-juggler": "latest",
2013-07-22 00:27:54 +00:00
"loopback-connector-mysql": "latest"
2012-12-14 14:01:44 +00:00
},
...
}
```
2. Use:
```javascript
2013-09-24 22:14:23 +00:00
var DataSource = require('loopback-datasource-juggler').DataSource;
var dataSource = new DataSource('mysql', {
2013-10-14 22:19:04 +00:00
host: 'localhost',
port: 3306,
2013-10-03 21:50:38 +00:00
database: 'mydb',
username: 'myuser',
password: 'mypass'
2012-12-14 14:01:44 +00:00
});
```
2013-10-03 21:50:38 +00:00
You can optionally pass a few additional parameters supported by [`node-mysql` ](https://github.com/felixge/node-mysql ),
2013-09-24 22:14:23 +00:00
most particularly `password` and `collation` . `Collation` currently defaults
to `utf8_general_ci` . The `collation` value will also be used to derive the
connection charset.
2012-12-14 14:01:44 +00:00