Skip to content
This page View Markdown Open in ChatGPT Open in Claude

MariaDB connection strings

MariaDB takes the same connection strings as MySQL, with mariadb:// or mysql:// in front.

The format

mariadb://user:password@host:port/database
Part What it is
mariadb:// mysql:// works too.
user:password@ The user and its password. Write the password as it is, even with @ or : in it : API Maker encodes it before it connects.
host:port 3306 when no port is given.
/database Optional : the database a connection starts in. An instance reaches every database its user may read.

API Maker reads the user, the password, the host, the port and the database, and nothing else : options after ? are not read (?multipleStatements=true in the sample secret changes nothing).

No TLS to MySQL and MariaDB

API Maker v4 connects to MySQL, MariaDB, Percona Server and TiDB without TLS. Keep the database on the same server or on a private network, or reach it through an SSH tunnel or a VPN. A server which requires TLS (require_secure_transport=ON, the default of some managed services) refuses the connection.

Examples

# 1. MariaDB on the same server
mariadb://root:[email protected]:3306

# 2. A database to start in
mariadb://app:[email protected]:3306/inventory

# 3. Another port
mariadb://app:[email protected]:3308/inventory

# 4. One node of a Galera cluster
mariadb://app:[email protected]:3306/inventory

# 5. A password with special characters, written as it is
mariadb://app:p@ss:[email protected]:3306/inventory

A connection string names one server. For a Galera cluster, give API Maker the address of one node, or of a load balancer in front of the nodes.

Add it to API Maker

An instance never holds the connection string itself : it names a key of your default secret, where the string stays encrypted, out of Git.

  1. Put the string in the secret Security → Secret Management → Default. Add it under common.connectionString, with a name of your choice, and save.
  2. Create the instance APIs & Logic → Instance API (DB API) → add an instance : pick the database type, give it a name, and pick the key of the secret under Connection.
  3. Test it Test Instance connects with the string. An instance which can not reach its database is not saved, and the form says why.

Connection String Sandbox is optional : a second key, for code which runs in a sandbox and reaches the database by another address than API Maker does.

Common errors

What you see What to check
Access denied for user 'app'@'10.0.0.2' The password, and a user allowed from the address of API Maker : CREATE USER 'app'@'10.0.0.2', or 'app'@'%'.
A timeout, or the connection refused The server listens on the network (bind-address), the firewall lets API Maker in, the port is right.
Invalid URL : … The string starts with mysql:// or mariadb:// and names a host.
The server asks for TLS Not supported, see above.