2016-10-31 21:02:14 +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/ ).
2016-10-31 21:02:14 +00:00
For complete documentation, see [StrongLoop Documentation | MySQL Connector ](http://loopback.io/doc/en/lb2/MySQL-connector.html ).
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
2015-03-15 21:41:46 +00:00
## Running Tests
2015-03-18 05:27:30 +00:00
The tests in this repository are mainly integration tests, meaning you will need to run them using our preconfigured test server.
2015-03-15 21:41:46 +00:00
2015-03-18 05:26:09 +00:00
1. Ask a core developer for instructions on how to set up test server credentials on your machine
2015-03-15 21:41:46 +00:00
2. `npm test`