[MySQL](https://www.mysql.com/) is a popular open-source relational database management system (RDBMS). The `loopback-connector-mysql` module provides the MySQL connector module for the LoopBack framework.
This installs the module from npm and adds it as a dependency to the application's`package.json`file.
If you create a MySQL data source using the data source generator as described below, you don't have to do this, since the generator will run `npm install` for you.
## Creating a MySQL data source
Use the[Data source generator](http://loopback.io/doc/en/lb3/Data-source-generator.html)to add a MySQLdata source to your application.
The generator will prompt for the database server hostname, port, and other settings
required to connect to a MySQL database. It will also run the `npm install` command above for you.
The entry in the application's `/server/datasources.json` will look like this:
```javascript
"mydb": {
"name": "mydb",
"connector": "mysql",
"host": "myserver",
"port": 3306,
"database": "mydb",
"password": "mypassword",
"user": "admin"
}
```
Edit `datasources.json` to add any other additional properties that you require.
### Properties
<table>
<thead>
<tr>
<thwidth="150">Property</th>
<thwidth="80">Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>collation</td>
<td>String</td>
<td>Determines the charset for the connection. Default is utf8_general_ci.</td>
</tr>
<tr>
<td>connector</td>
<td>String</td>
<td>Connector name, either “loopback-connector-mysql” or “mysql”.</td>
</tr>
<tr>
<td>connectionLimit</td>
<td>Number</td>
<td>The maximum number of connections to create at once. Default is 10.</td>
</tr>
<tr>
<td>database</td>
<td>String</td>
<td>Database name</td>
</tr>
<tr>
<td>debug</td>
<td>Boolean</td>
<td>If true, turn on verbose mode to debug database queries and lifecycle.</td>
</tr>
<tr>
<td>host</td>
<td>String</td>
<td>Database host name</td>
</tr>
<tr>
<td>password</td>
<td>String</td>
<td>Password to connect to database</td>
</tr>
<tr>
<td>port</td>
<td>Number</td>
<td>Database TCP port</td>
</tr>
<tr>
<td>socketPath</td>
<td>String</td>
<td>The path to a unix domain socket to connect to. When used host and port are ignored.</td>
</tr>
<tr>
<td>supportBigNumbers</td>
<td>Boolean</td>
<td>Enable this option to deal with big numbers (BIGINT and DECIMAL columns) in the database. Default is false.</td>
The MySQL connector supports _model discovery_ that enables you to create LoopBack models
based on an existing database schema using the unified[database discovery API](http://apidocs.strongloop.com/loopback-datasource-juggler/#datasource-prototype-discoverandbuildmodels). For more information on discovery, see [Discovering models from relational databases](https://loopback.io/doc/en/lb3/Discovering-models-from-relational-databases.html).
The MySQL connector also supports _auto-migration_ that enables you to create a database schema
from LoopBack models using the [LoopBack automigrate method](http://apidocs.strongloop.com/loopback-datasource-juggler/#datasource-prototype-automigrate).
For more information on auto-migration, see[Creating a database schema from models](https://loopback.io/doc/en/lb3/Creating-a-database-schema-from-models.html) for more information.
Destroying models may result in errors due to foreign key integrity. First delete any related models first calling delete on models with relationships.