Skip to content

Commit 51917f1

Browse files
committed
Better docs for connection options
1 parent 605f87b commit 51917f1

File tree

1 file changed

+22
-10
lines changed

1 file changed

+22
-10
lines changed

Readme.md

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -92,16 +92,9 @@ The recommended way to establish a connection is this:
9292
```js
9393
var mysql = require('mysql');
9494
var connection = mysql.createConnection({
95-
host : String, // defaults to 'localhost'
96-
port : Number, // defaults to 3306
97-
socketPath : String, // defaults to undefined
98-
user : String, // defaults to undefined
99-
password : String, // defaults to undefined
100-
database : String, // defaults to undefined
101-
charset : String, // defaults to 'UTF8_GENERAL_CI'
102-
insecureAuth : Boolean, // defaults to false
103-
typeCast : Boolean, // defaults to true
104-
debug : Boolean, // defaults to false
95+
host : 'example.org',
96+
user : 'bob',
97+
password : 'secret',
10598
});
10699

107100
connection.connect(function(err) {
@@ -125,6 +118,25 @@ appropriate. Any type of connection error (handshake or network) is considered
125118
a fatal error, see the [Error Handling](#error-handling) section for more
126119
information.
127120

121+
## Connection options
122+
123+
When establishing a connection, you can set the following options:
124+
125+
* `host`: The hostname of the database you are connecting to. (Default:
126+
`localhost`)
127+
* `port`: The port number to connect to. (Default: `3306`)
128+
* `socketPath`: The path to a unix domain socket to connect to. When used `host`
129+
and `port` are ignored.
130+
* `user`: The MySQL user to authenticate as.
131+
* `password`: The passqword of that MySQL user.
132+
* `database`: Name of the database to use for this connection (Optional).
133+
* `charset`: The charset for the connection. (Default: `'UTF8_GENERAL_CI'`)
134+
* `insecureAuth`: Allow connecting to MySQL instances that ask for the old
135+
(insecure) authentication method. (Default: `false`)
136+
* `typeCast`: Determines if column values should be converted to native
137+
JavaScript types. (Default: `true`)
138+
* `debug`: Prints protocol details to stdout. (Default: `false`)
139+
128140
## Terminating connections
129141

130142
There are two ways to end a connection. Terminating a connection gracefully is

0 commit comments

Comments
 (0)