Connect to MySQL

suggest change

One of the easiest ways to connect to MySQL is by using mysql module. This module handles the connection between Node.js app and MySQL server. You can install it like any other module:

npm install --save mysql

Now you have to create a mysql connection, which you can later query.

const mysql      = require('mysql');
const connection = mysql.createConnection({
  host     : 'localhost',
  user     : 'me',
  password : 'secret',
  database : 'database_schema'
});

connection.connect();

// Execute some query statements
// I.e. SELECT * FROM FOO

connection.end();

In the next example you will learn how to query the connection object.

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:


MySQL integration:
* Connect to MySQL

Table Of Contents
1 npm
7 MySQL integration
41 cli
43 grunt
59 Hack
64 ES6
67 Redis
69 MongoDB
86 MongoDB
87 Lodash
91 CORS
105 N-API
108 Require