Free tool · no account
PostgreSQL and MySQL connection string builder
Fill in the fields or paste an existing connection string, and get it back in every format your tools expect - with special characters in the password encoded correctly for each one. It all runs in your browser.
URL, JDBC, PDO DSN, or libpq keyword/value.
Only verify-ca and verify-full check the server certificate.
postgresql://localhost:5432/
libpq, psql, and most PostgreSQL drivers and frameworks accept this form.
host=localhost port=5432
jdbc:postgresql://localhost:5432/
For the PostgreSQL JDBC driver (pgjdbc).
pgsql:host=localhost;port=5432
Pass the user name and password as the second and third arguments to new PDO().
DB_CONNECTION=pgsql DB_HOST=localhost DB_PORT=5432 DB_DATABASE= DB_USERNAME= DB_PASSWORD= # or, instead of the five lines above: # DB_URL=postgresql://localhost:5432/
psql postgresql://localhost:5432/
The password ends up in your shell history. Prefer leaving it out and letting psql prompt, or a ~/.pgpass file.
Runs entirely in your browser. Nothing you enter is sent to Shortspan or saved, and no account is needed.
Next step
Or connect without handling the password at all
Register the database in Shortspan once, and shortspan db <alias> launches your client with a brokered credential - directly, through an SSH bastion, or on the server itself. Developers connect without ever seeing the password, and every connection is recorded.
Why passwords break connection strings
In a URL, @ separates the credentials from the host, : separates the user from the password, and /, ?, and # start the path, query, and fragment. A password containing any of them has to be percent-encoded - @ becomes %40 - or the driver reads the wrong host, or none at all.
Other formats escape differently. libpq keyword/value strings quote values in single quotes and escape ' and \. Dotenv files interpolate $ inside double quotes, so a password with a dollar sign needs single quotes. This tool applies the right rule for each format.
SSL modes
PostgreSQL’s sslmode ranges from disable to verify-full; only verify-ca and verify-full check the server certificate, and only verify-full checks that it belongs to the host you meant. MySQL names its equivalents REQUIRED, VERIFY_CA, and VERIFY_IDENTITY, spelled ssl-mode for MySQL Shell and sslMode for Connector/J.
Formats it reads
Paste a postgresql://, postgres://, mysql://, or mariadb:// URL, either with a jdbc: prefix, a PHP PDO DSN, or a libpq keyword/value string, and the fields fill in.
Common questions
- How do I put special characters in a PostgreSQL password in a URL?
- Percent-encode them:
@is%40,:is%3A,/is%2F,#is%23, and a space is%20. Enter the raw password in the tool and copy the URL it builds. - What is the default port?
- 5432 for PostgreSQL and 3306 for MySQL. The tool fills the default in when a pasted string leaves the port out.
- Is the password sent anywhere?
- No. Parsing and building happen in your browser, and nothing is saved. Even so, avoid pasting a production password into any page you do not control.
- Why does the mysql command not include the password?
- A password passed on the command line is visible to other users in the process list and stays in your shell history. With
-pand no value, the client prompts for it instead.
More free tools