Node.js connects to MySQL


  Translation results:

Node.js is a platform built on the Chrome JavaScript runtime.

Node.js is an event-driven I/O server-side JavaScript environment based on Google's V8 engine. The V8 engine executes Javascript very quickly and has very good performance.

Node.js connects to MySQLsyntax

Use Node.js to connect to MySQL and operate the database.

Node.js connects to MySQLexample

var mysql      = require('mysql');
var connection = mysql.createConnection({
  host     : 'localhost',  user     : 'root',  password : '123456',  database : 'test'}); 
connection.connect(); 
connection.query('SELECT 1 + 1 AS solution', function (error, results, fields) {
  if (error) throw error;  
console.log('The solution is: ', results[0].solution);});

Popular Recommendations

Home

Videos

Q&A