MariaDB connection strings
MariaDB speaks the MySQL protocol, so the MySQL forms mostly work — but its own connectors differ where it matters: Connector/J 3 wants jdbc:mariadb:// and has its own sslMode values, and recent clients check the server's certificate by default. Below is each form for the same database.
Build yours (MariaDB)The parts of a MariaDB connection string
The shape
jdbc:mariadb://host:3306/database?user=…&password=…&sslMode=verify-full
- jdbc:mariadb://
- Connector/J 3 rejects jdbc:mysql:// unless permitMysqlScheme is set.
- host:3306
- Same default port as MySQL.
- sslMode=
- disable, trust (encrypt, don't check), verify-ca or verify-full.
One MariaDB database, every form
User app_user, password s3cret-Pa55, database shop on db.example.com, tls, verify the certificate.
URI
Node (mariadb connector), Prisma (as mysql://), DATABASE_URL · connected with on a real server
mariadb://app_user:s3cret-Pa55@db.example.com:3306/shop
TLS is not part of this URL: each library sets it its own way (an ssl option in mysql2 and the mariadb connector).
JDBC (MariaDB Connector/J 3)
Java, DBeaver, IntelliJ, Spring
jdbc:mariadb://db.example.com:3306/shop?user=app_user&password=s3cret-Pa55&sslMode=verify-full
SQLAlchemy
Python with SQLAlchemy and PyMySQL · connected with on a real server
mariadb+pymysql://app_user:s3cret-Pa55@db.example.com:3306/shop
For TLS pass connect_args={"ssl": {...}} to create_engine; PyMySQL takes no TLS setting in the URL.
Go DSN (go-sql-driver/mysql)
Go database/sql
app_user:s3cret-Pa55@tcp(db.example.com:3306)/shop?parseTime=true&tls=true
Not a URL: the password goes in as it is, with no percent-encoding.
.NET (MySqlConnector)
C#, EF Core (Pomelo)
Server=db.example.com;Port=3306;Database=shop;User ID=app_user;Password=s3cret-Pa55;SslMode=VerifyFull
mariadb command
Shell · connected with on a real server
mariadb -h db.example.com -P 3306 -u app_user -p --ssl --ssl-verify-server-cert shop
-p with nothing after it asks for the password, so it stays out of your shell history.
A password with special characters
The same database with the password p@ss/w#rd 1. URLs encode it, key=value forms quote it, and each form does it differently:
URI
mariadb://app_user:p%40ss%2Fw%23rd%201@db.example.com:3306/shop
JDBC (MariaDB Connector/J 3)
jdbc:mariadb://db.example.com:3306/shop?user=app_user&password=p%40ss%2Fw%23rd%201&sslMode=verify-full
SQLAlchemy
mariadb+pymysql://app_user:p%40ss%2Fw%23rd%201@db.example.com:3306/shop
Go DSN (go-sql-driver/mysql)
app_user:p@ss/w#rd 1@tcp(db.example.com:3306)/shop?parseTime=true&tls=true
| Character | In a URL | Why it breaks |
|---|---|---|
| @ | %40 | Ends the user name and password: everything after the first unencoded @ is read as the host. |
| : | %3A | Separates user from password, and host from port. |
| / | %2F | Starts the database name. |
| ? | %3F | Starts the options. |
| # | %23 | Starts a fragment: the rest of the string is thrown away. |
| % | %25 | Starts an escape itself, so a literal % must be escaped too. |
| & | %26 | Separates options. |
| + | %2B | Some parsers (PyMongo among them) read + as a space. |
| space | %20 | Ends the string on a command line, and is trimmed by some parsers. |
TLS: what each setting looks like
Shown in the JDBC (MariaDB Connector/J 3) form; the builder writes the matching setting for every other one.
No TLS
jdbc:mariadb://db.example.com:3306/shop?user=app_user&password=s3cret-Pa55
TLS, don't check the certificate
jdbc:mariadb://db.example.com:3306/shop?user=app_user&password=s3cret-Pa55&sslMode=trust
TLS, verify the certificate
jdbc:mariadb://db.example.com:3306/shop?user=app_user&password=s3cret-Pa55&sslMode=verify-full
What catches people out on MariaDB
Connector/J 3 dropped jdbc:mysql://
Version 3 of the MariaDB JDBC driver only answers to jdbc:mariadb://, so it can sit next to MySQL's driver in one application. Old URLs need the scheme changed (or permitMysqlScheme added).
Different sslMode words from MySQL
MariaDB Connector/J uses disable, trust, verify-ca and verify-full; MySQL's Connector/J uses DISABLED, REQUIRED, VERIFY_CA, VERIFY_IDENTITY. Copying one into the other is ignored or refused.
Newer clients verify the certificate by default
From MariaDB 11.4 the client checks the server certificate unless told not to. Against a self-signed certificate, add --skip-ssl-verify-server-cert, or better, give the server a certificate the client trusts.
root may log in by socket only
Since 10.4, root@localhost can authenticate with unix_socket: sudo mariadb works, and the same login over TCP with a password may not. Create a separate user for applications.
Connected. Now what?
Paste the same string into DBShifts to browse MariaDB with sensitive columns masked and every read logged, or to migrate it to another database with each table counted and checksummed afterwards.
Questions
Can I use a MySQL connection string with MariaDB?
Mostly: the protocol is the same, so mysql:// URLs, the Go driver and MySqlConnector work. The MariaDB JDBC driver is the exception — Connector/J 3 needs jdbc:mariadb:// and its own sslMode values.
What is the MariaDB JDBC URL format?
jdbc:mariadb://host:3306/database?user=…&password=…, with sslMode=trust or sslMode=verify-full for TLS. Percent-encode special characters in the password.
What is the default MariaDB port?
3306, the same as MySQL.
More on MariaDB
Other databases
PostgreSQL connection strings
postgresql://user:password@host:5432/database?sslmode=verify-full
MySQL connection strings
mysql://user:password@host:3306/database
SQL Server connection strings
Server=tcp:host,1433;Database=…;User Id=…;Password=…;Encrypt=True;
Oracle connection strings
host:1521/service_name
MongoDB connection strings
mongodb://user:password@host:27017/database?authSource=admin&tls=true
SQLite connection strings
sqlite:////var/data/app.db