Configuration

mysql-async is configured by setting set mysql_connection_string "[string]". The connection string can either be formatted like an url:

set mysql_connection_string "mysql://user:password@host/database?charset=utf8mb4"

Here options are chained &. The other option is to to use an option string where each variable is seperated by an ;, which would look like:

set mysql_connection_string "database=mysqlasync;charset=utf8mb4"

The configuration options available for these strings are listed below.

Configuration Options

This is taken directly from the mysql.js Readme file, but trimmed to only applicable connection and pooling options, or changed a bit to accomodate legacy settings.

host | server | data source | datasource | addr | address

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 | user id | userid | user name | username | uid

The MySQL user to authenticate as.

password | pwd

The password of that MySQL user.

database | initial catalog

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. (Default: false)

insecureAuth

Allow connecting to MySQL instances that ask for the old (insecure) authentication method. (Default: false)

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 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 [-253, +253] range), otherwise they will be returned as Number objects. This option is ignored if supportBigNumbers is disabled.

debug

Prints protocol details to stdout. Can be true/false or an array of packet type names that should be printed. (Default: false)

trace

Generates stack traces on Error to include call site of library entrance ("long stack traces"). Slight performance penalty for most calls. (Default: true)

localInfile

Allow LOAD DATA INFILE to use the LOCAL modifier. (Default: true)

multipleStatements

Allow multiple mysql statements per query. Be careful with this, it could increase the scope of SQL injection attacks. (Default: false)

flags

List of connection flags to use other than the default ones. It is also possible to blacklist default ones. For more information, check Connection Flags.

ssl

Object with ssl parameters or a string containing name of ssl profile. See SSL options.

acquireTimeout

The milliseconds before a timeout occurs during the connection acquisition. This is slightly different from connectTimeout, because acquiring a pool connection does not always involve making a connection. If a connection request is queued, the time the request spends in the queue does not count towards this timeout. (Default: 10000)

waitForConnections

Determines 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)

connectionLimit

The maximum number of connections to create at once. (Default: 10)

queueLimit

The 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)

Additional Configuration Options

These additional configuration are to be set in the server configuration file, in a similar way to setting the mysql_connection_string.

mysql_debug

Possible options are Console, File, FileAndConsole and None. In case of a file output, the file will be located in the current working directory on starting the server, named like /<resourcename>-<timestamp>.log. The name of the file can be changed by setting mysql_log_file_format. (Default: None)

mysql_slow_query_warning

Sets a limit in millisecondss, queries slower than this limit will be displayed with a warning at the specified location of mysql_debug_output, see above (Default: 100)

mysql_log_level

This variable gives control over what goes to the console, and what does not. Add the numbers to get the value to set it to. 1: Info, 2: Success, 4: Warning, 8: Error. For example you wanted only Info's and Error's appearing in the server console, you would set it to 9. (Default: 15)

mysql_log_file_format

Sets the log file format, relative to the working directory of the server. If mysql_debug is not set to File or FileAndConsole, then this option is useless. %s is replaced with the name of the resource, %d is replaced by a timestamp. (Default: %s-%d.log)