Repository navigation
Configuration
A connection takes its settings in the options of MySQL_Connect, as key=value pairs separated by semicolons, or from a file read by MySQL_ConnectFile.
stock ConnectDatabase() {
return MySQL_Connect("127.0.0.1", "game", "secret", "game", 3306, "pool=2;read_timeout=10;slow_query=200");
}A setting that is not known, or a value that is not valid, makes the connection fail with INVALID_MYSQL_ID and a line in the log, so a typing mistake is never ignored.
| Setting | Default | Meaning |
|---|---|---|
charset |
latin1 |
Character set of the connection. latin1 is the code page of the game, so text reaches the client as it shows it. |
multi_statements |
false |
Whether a query may hold several statements separated by semicolons. Each gives a result set. |
pool |
0 |
Connections for MySQL_ParallelQuery, besides the one of the ordered queries. |
connect_timeout |
none | Seconds to wait for the server when connecting. |
read_timeout |
none | Seconds to wait for the answer of a query. A query that takes longer fails, and the connection opens again. |
write_timeout |
none | Seconds to wait when sending a query. |
slow_query |
0 |
Milliseconds from which a query is logged with its time. 0 logs none. |
log_errors |
true |
Whether failed queries are logged. OnMySQLError is called either way. |
max_query_length |
0 |
Longest query in bytes. A longer one is refused. |
max_pending |
0 |
Most queries waiting or running at once. One past it is refused. |
max_queries_per_second |
0 |
Most queries sent in a second. One past it is refused. |
ssl and the other TLS settings |
off | See TLS. |
A query refused by a limit is not sent, the native that sent it returns false, its public is not called, and a line is logged, at most one a second. 0 sets no limit.
true, 1, yes and on turn a setting on.
MySQL_ConnectFile reads mysql.ini from the folder of the server by default. Each line holds a key = value setting. It takes the keys of the mysql.ini of the R41 plugin, besides every setting above:
| Key | Meaning |
|---|---|
hostname |
Name or address of the server. |
username |
Account to log in with. |
password |
Password of the account. |
database |
Database the queries use. |
server_port |
Port of the server, 3306 by default. |
pool_size |
The same as pool. |
ssl_enable |
The same as ssl. |
ssl_ca_file, ssl_ca_path, ssl_cert_file, ssl_key_file
|
The same as ssl_ca, ssl_capath, ssl_cert and ssl_key. |
auto_reconnect |
Accepted and ignored, as the component always connects again. |
hostname = 127.0.0.1
username = game
password = ${MYSQL_PASSWORD}
database = game
pool = 2
slow_query = 200A value takes ${NAME} from the environment of the server, so the password needs not be written in the file, nor kept in a repository with it. A variable that is not set makes the file not valid, rather than connecting with an empty password.
A connection that fails or is lost is opened again by the next query. After a failure the component waits half a second before it tries again, then twice as long after each next failure, up to five seconds. The queries sent while it waits fail at once with the error of the last attempt, so a database that is down never holds the queue. A connection unused for a while is checked before its next query.
MySQL 0.2.0 · Repository · Releases · MIT License
Guides
- Installation
- Configuration
- Queries
- Results
- JSON cells
- Prepared statements
- Passwords
- Errors
- TLS
- Coming from R41
- Performance
Reference
Functions