# mysql
[![NPM Version][npm-version-image]][npm-url]
[![NPM Downloads][npm-downloads-image]][npm-url]
[![Node.js Version][node-image]][node-url]
[![Linux Build][travis-image]][travis-url]
[![Windows Build][appveyor-image]][appveyor-url]
[![Test Coverage][coveralls-image]][coveralls-url]
## Table of Contents
- [Install](#install)
- [Introduction](#introduction)
- [Contributors](#contributors)
- [Sponsors](#sponsors)
- [Community](#community)
- [Establishing connections](#establishing-connections)
- [Connection options](#connection-options)
- [SSL options](#ssl-options)
- [Terminating connections](#terminating-connections)
- [Pooling connections](#pooling-connections)
- [Pool options](#pool-options)
- [Pool events](#pool-events)
- [Closing all the connections in a pool](#closing-all-the-connections-in-a-pool)
- [PoolCluster](#poolcluster)
- [PoolCluster options](#poolcluster-options)
- [Switching users and altering connection state](#switching-users-and-altering-connection-state)
- [Server disconnects](#server-disconnects)
- [Performing queries](#performing-queries)
- [Escaping query values](#escaping-query-values)
- [Escaping query identifiers](#escaping-query-identifiers)
- [Preparing Queries](#preparing-queries)
- [Custom format](#custom-format)
- [Getting the id of an inserted row](#getting-the-id-of-an-inserted-row)
- [Getting the number of affected rows](#getting-the-number-of-affected-rows)
- [Getting the number of changed rows](#getting-the-number-of-changed-rows)
- [Getting the connection ID](#getting-the-connection-id)
- [Executing queries in parallel](#executing-queries-in-parallel)
- [Streaming query rows](#streaming-query-rows)
- [Piping results with Streams](#piping-results-with-streams)
- [Multiple statement queries](#multiple-statement-queries)
- [Stored procedures](#stored-procedures)
- [Joins with overlapping column names](#joins-with-overlapping-column-names)
- [Transactions](#transactions)
- [Ping](#ping)
- [Timeouts](#timeouts)
- [Error handling](#error-handling)
- [Exception Safety](#exception-safety)
- [Type casting](#type-casting)
- [Connection Flags](#connection-flags)
- [Debugging and reporting problems](#debugging-and-reporting-problems)
- [Security issues](#security-issues)
- [Contributing](#contributing)
- [Running tests](#running-tests)
- [Todo](#todo)
## Install
This is a [Node.js](https://nodejs.org/en/) module available through the
[npm registry](https://www.npmjs.com/).
Before installing, [download and install Node.js](https://nodejs.org/en/download/).
Node.js 0.6 or higher is required.
Installation is done using the
[`npm install` command](https://docs.npmjs.com/getting-started/installing-npm-packages-locally):
```sh
$ npm install mysql
```
For information about the previous 0.9.x releases, visit the [v0.9 branch][].
Sometimes I may also ask you to install the latest version from Github to check
if a bugfix is working. In this case, please do:
```sh
$ npm install mysqljs/mysql
```
[v0.9 branch]: https://github.com/mysqljs/mysql/tree/v0.9
## Introduction
This is a node.js driver for mysql. It is written in JavaScript, does not
require compiling, and is 100% MIT licensed.
Here is an example on how to use it:
```js
var mysql = require('mysql');
var connection = mysql.createConnection({
host : 'localhost',
user : 'me',
password : 'secret',
database : 'my_db'
});
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);
});
connection.end();
```
From this example, you can learn the following:
* Every method you invoke on a connection is queued and executed in sequence.
* Closing the connection is done using `end()` which makes sure all remaining
queries are executed before sending a quit packet to the mysql server.
## Contributors
Thanks goes to the people who have contributed code to this module, see the
[GitHub Contributors page][].
[GitHub Contributors page]: https://github.com/mysqljs/mysql/graphs/contributors
Additionally I'd like to thank the following people:
* [Andrey Hristov][] (Oracle) - for helping me with protocol questions.
* [Ulf Wendel][] (Oracle) - for helping me with protocol questions.
[Ulf Wendel]: http://blog.ulf-wendel.de/
[Andrey Hristov]: http://andrey.hristov.com/
## Sponsors
The following companies have supported this project financially, allowing me to
spend more time on it (ordered by time of contribution):
* [Transloadit](http://transloadit.com) (my startup, we do file uploading &
video encoding as a service, check it out)
* [Joyent](http://www.joyent.com/)
* [pinkbike.com](http://pinkbike.com/)
* [Holiday Extras](http://www.holidayextras.co.uk/) (they are [hiring](http://join.holidayextras.co.uk/))
* [Newscope](http://newscope.com/) (they are [hiring](https://newscope.com/unternehmen/jobs/))
## Community
If you'd like to discuss this module, or ask questions about it, please use one
of the following:
* **Mailing list**: https://groups.google.com/forum/#!forum/node-mysql
* **IRC Channel**: #node.js (on freenode.net, I pay attention to any message
including the term `mysql`)
## Establishing connections
The recommended way to establish a connection is this:
```js
var mysql = require('mysql');
var connection = mysql.createConnection({
host : 'example.org',
user : 'bob',
password : 'secret'
});
connection.connect(function(err) {
if (err) {
console.error('error connecting: ' + err.stack);
return;
}
console.log('connected as id ' + connection.threadId);
});
```
However, a connection can also be implicitly established by invoking a query:
```js
var mysql = require('mysql');
var connection = mysql.createConnection(...);
connection.query('SELECT 1', function (error, results, fields) {
if (error) throw error;
// connected!
});
```
Depending on how you like to handle your errors, either method may be
appropriate. Any type of connection error (handshake or network) is considered
a fatal error, see the [Error Handling](#error-handling) section for more
information.
## Connection options
When establishing a connection, you can set the following options:
* `host`: The hostname of the database you are connecting to. (Default:
`localhost`)
* `port`: The port number to connect to. (Default: `3306`)
* `localAddress`: The source IP address to use for TCP connection. (Optional)
* `socketPath`: The path to a unix domain socket to connect to. When used `host`
and `port` are ignored.
* `user`: The MySQL user to authenticate as.
* `password`: The password of that MySQL user.
* `database`: Name of the database to use for this connection (Optional).
* `charset`: The charset for the connection. This is called "collation" in the SQL-level
of MySQL (like `utf8_general_ci`). If a SQL-level charset is specified (like `utf8mb4`)
then the default collation for that charset is used. (Default: `'UTF8_GENERAL_CI'`)
* `timezone`: The timezone configured on the MySQL server. This is used to type cast server date/time values to JavaScript `Date` object and vice versa. This can be `'local'`, `'Z'`, or an offset in the form `+HH:MM` or `-HH:MM`. (Default: `'local'`)
* `connectTimeout`: The milliseconds before a timeout occurs during the initial connection
to the MySQL server. (Default: `10000`)
* `stringifyObjects`: Stringify objects instead of converting to values. See
issue [#501](https://github.com/mysqljs/mysql/issues/501). (Default: `false`)
* `insecureAuth`: Allow connecting to MySQL instances that ask for the old
(insecure) authentication method. (Default: `false`)
* `typeCast`: Determines if column values should be converted to native
JavaScript types. (Default: `true`)
* `queryFormat`: A custom query format function. See [Custom format](#custom-format).
* `supportBigNumbers`: When dealing with big numbers (BIGINT and DECIMAL columns) in the database,
you should enable this
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
毕业设计-基于express的毕业生管理系统.zip (1910个子文件)
016fddb049788d74198939a7691b4712 21KB
0227f29630396500bda3227416e9c2eb 47KB
03aa050069d1745b4395511063664084 47KB
0638c771f710bae7e5284f86bef683bf 150KB
0e542cc14d09ac4832d20bee2b8e29a3 47KB
1256845e6988cae312373134e0507f76 21KB
147cfa7954cd2654217d022d34fb0364 47KB
1b695f7eea101f4f77f59cfe8f150c45 21KB
23beedac7ff03d87b5c78db925aff4ed 150KB
294a06823e3921779a30370de67b5579 21KB
31cf445b242d611a47ec173d199ee36e 185KB
3d673a7b5ed5fb019a89995bd180dcdb 21KB
3fdb48078b096cb61632e0d4db3b38d9 154KB
44ab1ae1a8c8125b290bf658e1d7a200 47KB
4649d6eca6ea496fd25c555127573646 268KB
4933ba47595f2b86541429b494da8aac 38KB
4a974a95d95dedd39b520d5289794e11 21KB
4cb0891cf06d45eafbbbf472ca732f07 268KB
4dbb8343e5805fba469b2c541d64be83 47KB
64e98f8f0019444e77fc1d51f6c80804 150KB
6b79f2b3b353bc535634c958806e369c 33KB
6cbd2357eb9ac131317499a3d906fbf3 47KB
73738848901d43d5a01fe3c0913a58d8 150KB
77b7af0957453bbdfe6f66c8cfe3d558 44KB
7a14d435c36c8477a0c8f0dc6bf57149 15KB
7eb593e98a058d2e4a2be32a66770d30 21KB
a3959c3256ebbf6de3417b354e40ca09 21KB
a494d6ffa6a016d742c01f8115ac9c74 21KB
ad30ab52364c1f7d3dea65738dcc810a 47KB
ad542492269f3c0728491b86629d8672 184KB
LICENSE.APACHE2 586B
b19580e72184d1823763c932a7acf6b5 47KB
b5204c6ece7da2ed141b6f8129b2f1e9 21KB
baa907f331a81a83d0cd8e7445015a24 185KB
bfdc8b23b51f895bae2156a82195b834 24KB
range.bnf 619B
LICENSE.BSD 1KB
c3d6d64981686b70d9424d83f3a3b8de 21KB
cc3c85adf2a2182ae2611859db1e08e8 11KB
cross-env-shell.cmd 214B
cross-env.cmd 202B
nodemon.cmd 186B
nodetouch.cmd 186B
node-which.cmd 182B
mkdirp.cmd 176B
semver.cmd 176B
nopt.cmd 174B
which.cmd 172B
is-ci.cmd 166B
mime.cmd 164B
rc.cmd 160B
cross-env 331B
cross-env-shell 343B
pintuer.css 125KB
jquery-ui.css 31KB
index.css 5KB
admin.css 4KB
login.css 1KB
reset.css 879B
index.css 302B
df30cd224ee3e8138608b146d54bf23e 150KB
1588572792477.0376.doc 38KB
.DS_Store 6KB
.editorconfig 399B
eec6ed72a7d7fbb3a1a461149fb4f734 21KB
add.ejs 5KB
edit.ejs 5KB
resume.ejs 5KB
edit.ejs 5KB
index.ejs 5KB
add.ejs 5KB
edit.ejs 5KB
add.ejs 5KB
add.ejs 4KB
individual.ejs 4KB
check.ejs 4KB
check.ejs 4KB
enterp_info.ejs 4KB
stud_info.ejs 4KB
index.ejs 4KB
edit.ejs 4KB
index.ejs 4KB
add.ejs 4KB
enterprise.ejs 4KB
index.ejs 4KB
check.ejs 3KB
recruit_info.ejs 3KB
index.ejs 3KB
index.ejs 3KB
add.ejs 3KB
index.ejs 3KB
index.ejs 3KB
edit.ejs 3KB
edit.ejs 3KB
add.ejs 3KB
admin.ejs 3KB
index.ejs 2KB
index.ejs 2KB
index.ejs 2KB
index.ejs 2KB
共 1910 条
- 1
- 2
- 3
- 4
- 5
- 6
- 20
资源评论
马coder
- 粉丝: 1203
- 资源: 6602
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 1961ee27df03bd4595d28e24b00dde4e_744c805f7e4fb4d40fa3f695bfbab035_8(1).c
- mediapipe-0.9.0.1-cp37-cp37m-win-amd64.whl.zip
- windows注册表编辑工具
- mediapipe-0.9.0.1-cp37-cp37m-win-amd64.whl.zip
- 校园通行码预约管理系统20240522075502
- 车类型数据集6250张VOC+YOLO格式.zip
- The PyTorch implementation of STGCN.STGCN-main.zip
- 092300108.cpp
- 车类型数据集6000张VOC+YOLO格式.zip
- for daily read
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功