Database Password Generator
Database passwords are read by applications, not people, so they can be long and fully random. The catch is that some symbols break connection strings and config files. Generate a strong password for each database user and pick settings that will not trip up your driver.
Symbols in connection strings
Many apps store credentials as a URL such as postgres://user:password@host:5432/db. In that format, characters like @, :, ?, # and / have special meaning and must be percent-encoded, or the driver will misread where the password ends. The simplest fix is to turn symbols off and raise the length: 32 characters of letters and numbers gives about 187 bits of randomness, more than enough for any database account.
If your tool keeps the password in a separate field or environment variable rather than a URL, symbols are usually fine, but watch for $ in shell scripts and .env files, where it can be read as a variable.
One user per application
Create a separate database user for each app or service, with only the permissions it needs, rather than letting everything connect as root or postgres. That way a leak from one app does not expose every database, and you can rotate one password without redeploying everything else.
Questions
How long should a database password be?
Because no human types it, there is little reason to go below 32 characters. Check your database’s maximum, though; most modern versions of MySQL, PostgreSQL and MongoDB accept long passwords, but some managed services and older tools set their own limits.
Why does my app fail to connect after I set the new password?
The most common cause is a symbol that needs escaping in a URL, a shell script or a YAML or .env file. Try regenerating without symbols at a greater length. Also confirm you updated the password in every environment that uses that database user.
Can I use this for the root or postgres superuser?
Yes. Give the superuser a long, unique password, store it in a password manager or vault, and use it only for administration. Applications should connect with their own limited accounts instead of the superuser.
Protect your business with a security review and hardening from VYZEON.
See cybersecurity