MySQL

The mysql driver connects to MySQL using SQLx.

URL format

mysql://<user>[:<password>]@<host>[:<port>]/<database>[?<options>]

Options

OptionBehavior / default
ssl-modeTLS mode: DISABLED, PREFERRED, REQUIRED, VERIFY_CA, or VERIFY_IDENTITY. Default PREFERRED; alias sslmode.
ssl-caCA certificate file; alias sslca.
ssl-cert / ssl-keyClient certificate and key files; aliases sslcert and sslkey.
charsetConnection character set; default utf8mb4.
collationConnection collation; determined from the charset when omitted.
timezoneSession time zone; alias time-zone. Encode a plus sign as %2B.
socketLocal Unix socket path instead of TCP.
statement-cache-capacityPrepared-statement cache size; default 100.

Examples

rsql --url 'mysql://user:password@localhost:3306/example' -- 'SELECT VERSION();'
rsql --url 'mysql://user:password@db.example.com/example?ssl-mode=VERIFY_IDENTITY&ssl-ca=/path/ca.pem'

Usage notes

The default TCP port is 3306. Percent-encode reserved characters in credentials and option values. Use .tables and .describe to inspect the selected database. MariaDB and MySQL share the same connection implementation.