Menu

Connection Strings for MySQL, PostgreSQL and Redis: A Practical Reference
📰

Connection Strings for MySQL, PostgreSQL and Redis: A Practical Reference

DEV Community: redis·O Oliver·13 days ago
#iBjYv6CQ
#devtoredis#devto#dev#redis#database
Reading 0:00
15s threshold

Every database driver accepts a URL, but no two databases agree on what that URL means. You copy a mysql:// string into a Postgres client and get a cryptic handshake error. You paste a Redis password containing @ and the driver silently connects to the wrong host. These are not edge cases; they are the normal experience of moving between stacks.

Here is the format each one actually expects, and the parts that break.

The general shape

All three follow the same skeleton:

scheme://[user[:password]@]host[:port][/database][?param=value]

Enter fullscreen mode

Exit fullscreen mode

The differences live in the scheme name, the meaning of the path segment, how TLS is expressed, and which characters are legal in the password.

MySQL

mysql://app_user:[email protected]:3306/orders?ssl-mode=REQUIRED&charset=utf8mb4

Enter fullscreen mode

Exit fullscreen mode

Path is the database name.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.