OptionalPromiseOptionalauthOptionalauthOptionalbigOptionalcharsetThe 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')
OptionalcharsetOptionalcompressOptionalconnectOptionalconnectThe milliseconds before a timeout occurs during the initial connection to the MySQL server. (Default: 10 seconds)
OptionalconnectionThe maximum number of connections to create at once. (Default: 10)
OptionaldatabaseName of the database to use for this connection
OptionaldateForce date types (TIMESTAMP, DATETIME, DATE) to be returned as strings rather then inflated into JavaScript Date objects. Can be true/false or an array of type names to keep as strings.
(Default: false)
OptionaldebugThis will print all incoming and outgoing packets on stdout. You can also restrict debugging to packet types by passing an array of types (strings) to debug;
(Default: false)
OptionaldecimalDECIMAL and NEWDECIMAL types will be returned as numbers if this option is set to true ( default: false).
OptionalenableEnable keep-alive on the socket. (Default: true)
OptionalflagsList of connection flags to use other than the default ones. It is also possible to blacklist default ones
OptionalhostThe hostname of the database you are connecting to. (Default: localhost)
OptionalidleThe idle connections timeout, in milliseconds. (Default: 60000)
OptionalinfileBy specifying a function that returns a readable stream, an arbitrary stream can be sent when sending a local fs file.
OptionalinsecureAllow connecting to MySQL instances that ask for the old (insecure) authentication method. (Default: false)
OptionalisOptionaljsonForce JSON to be returned as string
(Default: false)
OptionalkeepIf keep-alive is enabled users can supply an initial delay. (Default: 0)
OptionallocalThe source IP address to use for TCP connection
OptionalmaxThe maximum number of idle connections. (Default: same as connectionLimit)
OptionalmaxOptionalmultipleAllow multiple mysql statements per query. Be careful with this, it exposes you to SQL injection attacks. (Default: false)
OptionalnamedOptionalnestOptionalpasswordThe password of that MySQL user
Optionalpassword1Alias for the MySQL user password. Makes a bit more sense in a multifactor authentication setup (see "password2" and "password3")
Optionalpassword22nd factor authentication password. Mandatory when the authentication policy for the MySQL user account requires an additional authentication method that needs a password. https://dev.mysql.com/doc/refman/8.0/en/multifactor-authentication.html
Optionalpassword33rd factor authentication password. Mandatory when the authentication policy for the MySQL user account requires two additional authentication methods and the last one needs a password. https://dev.mysql.com/doc/refman/8.0/en/multifactor-authentication.html
OptionalpasswordOptionalpoolOptionalportThe port number to connect to. (Default: 3306)
OptionalqueryA custom query format function
OptionalqueueThe maximum number of connection requests the pool will queue before returning an error from getConnection. If set to 0, there is no limit to the number of queued connection requests. (Default: 0)
OptionalrowsReturn each row as an array, not as an object.
This is useful when you have duplicate column names.
This can also be set in the QueryOption object to be applied per-query.
OptionalsocketThe path to a unix domain socket to connect to. When used host and port are ignored
Optionalsslobject with ssl parameters or a string containing name of ssl profile
OptionalstreamOptionalstringifyStringify objects instead of converting to values. (Default: 'false')
OptionalsupportWhen dealing with big numbers (BIGINT and DECIMAL columns) in the database, you should enable this option (Default: false)
OptionaltimezoneThe timezone used to store local dates. (Default: 'local')
OptionaltraceGenerates stack traces on Error to include call site of library entrance ('long stack traces'). Slight performance penalty for most calls. (Default: true)
OptionaltypeDetermines if column values should be converted to native JavaScript types.
true
It is not recommended (and may go away / change in the future) to disable type casting, but you can currently do so on either the connection or query level.
You can also specify a function to do the type casting yourself:
(field: Field, next: () => void) => {
return next();
}
WARNING:
YOU MUST INVOKE the parser using one of these three field functions in your custom typeCast callback. They can only be called once:
field.string();
field.buffer();
field.geometry();
Which are aliases for:
parser.parseLengthCodedString();
parser.parseLengthCodedBuffer();
parser.parseGeometryValue();
You can find which field function you need to use by looking at RowDataPacket.prototype._typeCast.
OptionaluriOptionaluserThe MySQL user to authenticate as
OptionalwaitDetermines the pool's action when no connections are available and the limit has been reached. If true, the pool will queue the connection request and call it when one becomes available. If false, the pool will immediately call back with an error. (Default: true)
Enabling both supportBigNumbers and bigNumberStrings forces big numbers (BIGINT and DECIMAL columns) to be always returned as JavaScript String objects (Default: false). Enabling supportBigNumbers but leaving bigNumberStrings disabled will return big numbers as String objects only when they cannot be accurately represented with JavaScript Number objects (which happens when they exceed the [-2^53, +2^53] range), otherwise they will be returned as Number objects. This option is ignored if supportBigNumbers is disabled.