Database Connection Strings, Demystified
July 6, 2026 · DevTools
A connection string looks trivial until it isn't. A special character in a password, a missing sslmode, or the wrong scheme for a managed cluster, and you're staring at an authentication error with no obvious cause. Here's how they're actually structured.
The universal shape
Most database URIs follow the same pattern:
scheme://username:password@host:port/database?option=value
Only the pieces change per database:
| Database | Scheme | Default port |
|---|---|---|
| PostgreSQL | postgresql | 5432 |
| MySQL | mysql | 3306 |
| MongoDB | mongodb | 27017 |
| Redis | redis | 6379 |
| SQLite | sqlite | — (file path) |
SQLite is the odd one out — it's a file, not a network service:
sqlite:///data/app.db
The gotcha: passwords with special characters
This is the single most common reason a connection string silently breaks. If your password is p@ss:w0rd, this is wrong:
postgresql://admin:p@ss:w0rd@localhost:5432/mydb
The @ and : are structural characters in a URI — the parser sees a different host and port. You must percent-encode them:
postgresql://admin:p%40ss%3Aw0rd@localhost:5432/mydb
@ → %40, : → %3A, / → %2F, and so on. The Database Connection String Builder does this automatically as you type, so you never hit this class of bug. (If you just need to encode one value, the URL Encoder / Decoder handles it too.)
SSL and its many spellings
Every database spells "use TLS" differently:
- PostgreSQL:
?sslmode=require - MySQL:
?ssl-mode=REQUIRED - Redis: change the scheme to
rediss:// - MongoDB:
?tls=true
Forgetting this against a managed database that requires TLS gives a connection-refused error that looks like a network problem but isn't.
MongoDB's mongodb+srv
Managed MongoDB (like Atlas) uses a DNS seed list instead of a fixed host and port:
mongodb+srv://admin:secret@cluster.example.com/mydb
Note there's no port — the +srv scheme resolves the replica set members via DNS SRV records. Mixing up mongodb:// and mongodb+srv:// is a frequent copy-paste mistake.
JDBC and libpq variants
If you're in the JVM world, the same connection wants a JDBC URL:
jdbc:postgresql://localhost:5432/mydb?sslmode=require
And psql/libpq-based tools accept a keyword/value string:
host=localhost port=5432 dbname=mydb user=admin password=secret sslmode=require
The Database Connection String Builder emits all of these from one form — the URI, the JDBC URL and the libpq string — so you can grab whichever your driver expects. It runs entirely in your browser, so your credentials never leave your machine.