# mysql
[![NPM Version][npm-image]][npm-url]
[![NPM Downloads][downloads-image]][downloads-url]
[![Node.js Version][node-version-image]][node-version-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)
- [Contributing](#contributing)
- [Running tests](#running-tests)
- [Todo](#todo)
## Install
```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 option (Default: `false`).
* `bigNumberStrings`: Enabling both `supportBigNumbers` and `bigNumberStrings` forces big numbers
(BIGINT and DECIMAL columns) to be always returned as J
没有合适的资源?快使用搜索试试~ 我知道了~
node.js+express+mysql实现增删改查+分页+文件上传
共757个文件
js:224个
md:127个
json:91个
4星 · 超过85%的资源 需积分: 42 73 下载量 47 浏览量
2017-12-25
15:12:14
上传
评论 5
收藏 5.6MB RAR 举报
温馨提示
node.js+express+mysql实现增删改查+分页,以及图片上传操作
资源推荐
资源详情
资源评论
收起资源包目录
node.js+express+mysql实现增删改查+分页+文件上传 (757个子文件)
01880b0a83413ec0a627db1cb14ede0a0700e4 430B
0230bac64b458889ae0e4ca8248141ef81fcf6 5KB
0310d6cfaf4d1633e9c6f6ca267832ba943690 251B
081b774c5b26e97a3956741ea6188903bb4eca 4KB
08ecd0a8ca1ec609529d3a0b76106c48e418a0 91B
0c42b984c56b6f03396f34c5d74bd9c6e63539 631B
0e003894dafe5a4acc6ce5ff1d455663d53165 2KB
0ee21f7bbf585b750e294ed7b485bbb1a0c06c 185B
101caeab912b013843560996183a0bc9e1654b 1KB
10f3622f13c7b60c76ce7cd6f79947f94190ae 2KB
130213c5b91c275c21208de37eb1f5aa04bad6 185B
13693bf88aa9c0f3d131d11f7e3efd7c0e3e8e 2KB
141928799d49768ddb8fcc2b17229ab1e87cb0 1007B
16858e3ec43dbdf04c7b6c349e167f90ecb78b 66B
1796d37b39f1e983b35e6b920ec329c562d633 9KB
1d5f53e0b2920430ca394f18c9ee179bbbcfc0 3KB
1e71076d700501a8181f9f6e28a4280ed368b2 76B
234fc17a2f0171fdb859a86e8cd088e36ede51 250B
23d5d269df0e3771febbe94cb0f5d1a7e7bd79 1KB
2488d04f5dfddb29c5feabbe2407a9ac057413 187B
26bc3c67d3422110befe1a5a3da56bfec1c259 862B
26fa1021309e1c8815428014279ce6efec9557 165B
2729b6d8febb93abb99e4f49c655f2fdfa83d1 827B
29c03b40e29ccf2cb0c8894ac8b2170a2598a5 113B
2a66d9d40a1f4d4ea7ebb574e9777dfe5bdf8a 805B
2bd9054e9fa40e1e7ac63a4059f52ae84e948e 749B
2ee9b1307dacc6091cb8d3d11eff87f49a6d86 286B
2f108e2e7db7b1df0f2e03f9dcf1c9c7930cea 552KB
2f64d2d8ba51c1acf11b0715bd392724313f91 92B
2f767ece7bacfa036f6eacc3a5a8ad2f9e2f56 2KB
3042f863dca6b535eb082f55aa377846b2b27a 481B
3381f8f4449fa4ff16b715104d19cddd3a96ca 719B
355694e79c0310f8a73e674087e332ddd0c7b0 763B
3a15aef5e1152e401069f14ac415b9f1c5b6d7 1KB
3aeecb98aa2b05d2dc1fcd623afcb37204828a 12KB
3c37c6f3a974483d82009d184a40efd0e54e57 54B
40a07c1a0aa34c0f25ee0f94251fee7732d3ba 405B
41f2ed4439d9235f5e55802f17a01f7376780a 430B
455fa84d0e36d5475da01379864f82c615a8c5 45KB
487ce0752a17ad5ae12f6fe42cd8f79c899f24 250B
4a62f5ea1ea7c6953b0fc85208765f5cd81ec4 49B
50962f894a7b048ee4d39a1467d80afa6d6ce1 683B
51635c689328c7359f1b464f3dfca1fb3aaa98 4KB
52d44842792b719205f32ba91e4243bd096316 186B
53844186447e50779e1a5d63835e7fb7b134ce 92B
53852c2e36b90eb8d4ea0538633c927c890a69 154B
555cef5d7b344cf6a42a529a2e9d160f5ca0fe 1KB
591ed4c99230a877c2c12886bd4051d6c50599 4KB
59ca7a3aba3da6cd0239b3b30808b424ffbc47 957KB
5a8fc08de8c96701b8c79988e22458ac6dcdf0 1011B
5ab00358ac76f9701bb1ab65cf3f05766bd8bb 2KB
5c66b1ba297eeb3b5976b71c64c736b41bb763 25KB
600326cb81b7577dcf169ebcf20e9cf981eba8 616B
657f4411339930c485e2e154457bb39e5e0d37 221B
65dcd16fe95f94d3b7f9aa86751e5f3eb0997c 4KB
69cd1ca465f45826a3b74b134210a1df39a3d0 9KB
6a536e2f693270459aa11e08dcf58b9e2afa13 184B
6bf029d966b554a740c689f6b147f1b3648c31 311B
6e3e1097c15cb35ba7c556972a38e41f7ee984 87B
7107282fdfde74f321e2069c1a9fad5eb7ba80 3KB
7236e4edfa10d67622b05c7ce6ff031e1b7d99 6KB
7244d78df1fb849b12d3086d97eeb757a0b9ad 1KB
727ed6d64a49a81c149070a0af240e86f75201 6KB
7445166c0eab2fb8f33500dc3e1acc98b1f175 637B
747dabc7d934c6371a731637bd302ef5e56034 58B
74e1f131484a4b87d27a7d832541f3ca4ed3e4 858B
753c3b490a112947d05cf247ca7ab53f0e854c 182B
7596d245344aea1baabe1f760b145ae36ac008 646B
76a3b8224971549bdbb5e911d83191a7bbb635 3KB
7719e0a57984f9c2a9e62563df9d126ba84fc4 253B
81ac7f6d90235d62a8bdbce292b8b6fff7ff82 2KB
84eb39857769504b41fd8f2d5cd4cecd3d92f0 958B
8653ec3a948225a6d6ac07228a93261f8967bb 137B
868a4c0f4ae4857c665cb56ad6fb06857551fb 265B
877627860a429b3fd97e2b9fd551e9840142aa 86B
87c1adfe3536bffee7ef7b94103314a6fcf46d 2KB
88be5980c0bfd9f0aac4ecf6c4c9b9fc163a67 763B
8b551556acb365c26fb05a9fc29e6e1612408f 241B
8df0d5160eae9ebbcc2e0d683a433716d56946 2KB
8e5729f04a7afafbec4cf3c641bed0b837b187 718B
952786b8ed23db5c8bad4a3b199a1fe229ff0d 243B
987cbca237e69886b3a491f28b48006bb9d868 824B
99adf4efc88f060a230791fd96237f257df3eb 142B
9b24a0801ca122aa1522535b41fc3d1c40ba88 1022B
9b6690248dfc67dc445548313af3e9ba143ef3 5KB
a6a99e60ee9a5ce4d0922a3a82c6d81c1db7f2 34KB
a7339a90b4d7aa280dc4641ca8d7bd9ba53e91 247B
a868c6fbef327fc9a79f7488c265f666820f6c 82B
aa2550a7ceb6737be47bab18ca179aa1c5ed2e 1KB
aea43b8dd5e0d5c435fdbe9d8b67b737118d5a 282B
afed807992d0c1e979f2263f8b62fc4ce5ce51 251B
affe0ad0ca4e0b911c80eab677f00b8b99a0a2 380B
b37b52dec6faa7f48b9d1be5da2ad9b883be2f 662B
b446753698c41829cb44973e70fde814653526 2KB
b6376663f19ce2e2da85fd1dd11e2d8d4d3ed6 223B
b71171255f78b087185dba6e09f7bb6a74dd98 599B
b720285d5ddee10f1f956487c702c13836b4ff 140B
b72e30d430250b68fbb73a65c2f0445e035b23 1KB
b86a9acc425514cd91f37c5a9998d4c4acaa4a 4KB
b8f90897b7ab1652d3c4429e7f1609ffdfa6ee 238B
共 757 条
- 1
- 2
- 3
- 4
- 5
- 6
- 8
资源评论
- maplewsh2018-01-06采用的是 前台分页的方法,不是我想要的后台分页。Mysql 操作和文件上传,简单试了下 还可以。Anliexo2018-02-03只是一个简单的demo
Anliexo
- 粉丝: 80
- 资源: 12
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功