Connector/Node.js 是官方的node.js连接mysql的驱动,用于MySQL 5.7.12+ 以上数据库。在NodeJS开发中我们经常涉及到操作数据库,尤其是 MySQL,这是nodejs mysql 连接池。Nodejs要连接MySQL,可以使用Nodejs的MysQL驱动来实现。
mysql官方出品!
Installation
This library is organized in a way that it can be installed into your project using Node.js's npm tool. Choose one of the following methods to get and install MySQL Connector/node.js:
manually download the package from https://dev.mysql.com/downloads/connector/nodejs/ and import the library using npm:
$ npm install mysql-connector-nodejs-8.0.8.tar.gz`
use the @mysql/xdevapi package from https://npmjs.com and install it:
$ npm install @mysql/xdevapi
Please refer to https://npmjs.com for more information on npm.
Node.js中JavaScript操作MySQL方法
一、建立数据库连接:createConnection(Object)方法
该方法接受一个对象作为参数,该对象有四个常用的属性host,user