Optional
PromiseOptional
authOptional
authOptional
bigOptional
charsetThe 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')
Optional
charsetOptional
compressOptional
connectOptional
connectThe milliseconds before a timeout occurs during the initial connection to the MySQL server. (Default: 10 seconds)
Optional
connectionThe maximum number of connections to create at once. (Default: 10)
Optional
databaseName of the database to use for this connection
Optional
dateForce 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)
Optional
debugThis 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)
Optional
decimalDECIMAL and NEWDECIMAL types will be returned as numbers if this option is set to true
( default: false
).
Optional
enableEnable keep-alive on the socket. (Default: true)
Optional
flagsList of connection flags to use other than the default ones. It is also possible to blacklist default ones
Optional
hostThe hostname of the database you are connecting to. (Default: localhost)
Optional
idleThe idle connections timeout, in milliseconds. (Default: 60000)
Optional
infileBy specifying a function that returns a readable stream, an arbitrary stream can be sent when sending a local fs file.
Optional
insecureAllow connecting to MySQL instances that ask for the old (insecure) authentication method. (Default: false)
Optional
isOptional
jsonForce JSON to be returned as string
(Default: false)
Optional
keepIf keep-alive is enabled users can supply an initial delay. (Default: 0)
Optional
localThe source IP address to use for TCP connection
Optional
maxThe maximum number of idle connections. (Default: same as connectionLimit
)
Optional
maxOptional
multipleAllow multiple mysql statements per query. Be careful with this, it exposes you to SQL injection attacks. (Default: false)
Optional
namedOptional
nestOptional
passwordThe password of that MySQL user
Optional
password1Alias for the MySQL user password. Makes a bit more sense in a multifactor authentication setup (see "password2" and "password3")
Optional
password22nd 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
Optional
password33rd 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
Optional
passwordOptional
poolOptional
portThe port number to connect to. (Default: 3306)
Optional
queryA custom query format function
Optional
queueThe 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)
Optional
rowsReturn 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.
Optional
socketThe path to a unix domain socket to connect to. When used host and port are ignored
Optional
sslobject with ssl parameters or a string containing name of ssl profile
Optional
streamOptional
stringifyStringify objects instead of converting to values. (Default: 'false')
Optional
supportWhen dealing with big numbers (BIGINT and DECIMAL columns) in the database, you should enable this option (Default: false)
Optional
timezoneThe timezone used to store local dates. (Default: 'local')
Optional
traceGenerates stack traces on Error to include call site of library entrance ('long stack traces'). Slight performance penalty for most calls. (Default: true)
Optional
typeDetermines 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
.
Optional
uriOptional
userThe MySQL user to authenticate as
Optional
waitDetermines 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.