Advertisement

Free Online Database Connection String Builder

Build MySQL, PostgreSQL, and MongoDB connection strings.

Waiting for input
URI
DSN

Credentials are processed locally in your browser. Nothing is sent to a server.

Advertisement

About the Database Connection String Builder

A connection string is the compact piece of configuration that tells a database driver where the server lives and how to authenticate. It packs a host name, a network port, a database name, a username, and a password into one line that can be pasted into an environment variable, a secrets manager, a framework configuration file, or a container definition. Every database family has its own preferred shape: MySQL and PostgreSQL commonly appear as URI strings or PDO-style DSNs, while MongoDB is almost always addressed with a single mongodb URI that also carries replica set and authentication options.

This builder covers MySQL and MariaDB, PostgreSQL, and MongoDB. Fill in the host and port, choose the database, and add credentials. The tool assembles a percent-encoded URI and a driver-specific DSN at the same time. The URI output is useful for application frameworks, ORMs, and cloud platforms that accept a single connection URL. The DSN output is useful for PHP PDO, database clients, and libraries that expect a prefix such as mysql: or pgsql:. Port defaults follow each engine: 3306 for MySQL, 5432 for PostgreSQL, and 27017 for MongoDB.

Special characters matter. An at sign, colon, slash, or space inside a username or password can break a URI, because those characters have structural meaning. The builder percent-encodes the username, password, and database name before inserting them, so a password such as p@ss:w/rd becomes a safe sequence. DSN strings are not URL-encoded by drivers, so a semicolon inside a password can still cause problems. If you see connection failures with exotic credentials, prefer the URI form or escape the value according to your driver documentation.

Extra options can be supplied one per line as key=value. Typical examples include a character set for MySQL, a connection timeout, an authentication source for MongoDB, or an application name for PostgreSQL. The SSL selector adds the conventional parameter for the chosen engine: ssl for MySQL, sslmode for PostgreSQL, and tls for MongoDB. Because the checkbox for including the password is enabled by default, remember to uncheck it before sharing a screenshot or a support ticket.

How to use this tool

  1. Select the database engine. The default port changes to match it.
  2. Enter host, database, user, and password. Add extra options if your driver needs them.
  3. Click Build connection strings to generate the URI and DSN.
  4. Copy either output, or download both as a text file.

Frequently asked questions

Is the connection string tested against my database?

No. The tool only formats text. It never opens a network connection, so a valid-looking string can still fail if the server is unreachable or the credentials are wrong.

Why is the MongoDB DSN the same as the URI?

MongoDB drivers use the URI as their native connection format. There is no separate semicolon-delimited DSN, so the second panel repeats the URI with a short note.

Should I commit a connection string to source control?

No. Store it in an environment variable or a secrets manager. The password can be removed from the generated output with the include-password checkbox before you share it.

Sponsored
Find a bug? Report now