How to make a Postgresql database backup with pg_dump and a password

As a quick note, this is how I run the Postgresql pg_dump command to make a database backup while using a password:

pg_dump --no-owner \
        --dbname=postgresql://username:password@localhost:5432/databasename > database.sql

There are other ways to do this, as described on this SO page, but I prefer this solution, which I found on this page. Personally I’d rather have the database password right next to the command, rather than in some file I’ll forget about two weeks from now.