amacneil / dbmate

🚀 A lightweight, framework-agnostic database migration tool.
MIT License
5.39k stars 267 forks source link

Postgresql Passwords with special characters #212

Closed joagranadosme closed 3 years ago

joagranadosme commented 3 years ago

I'm trying to run migrations on Postgres. The password is ]Srs\|^[P-{tNhoDy5E4t.*G but the following error appears

Error: parse net/url: invalid userinfo

Is there any way to escape the special characters on Postgres building the URL with the format?

DATABASE_URL="postgres://${postgres_user}:${postgres_password}@${postgres_host}:${postgres_port}/${postgres_db}?sslmode=disable"

amacneil commented 3 years ago

I believe you just need to URL encode the password. How to do that depends on which language you are using, but you can do it online here: https://www.w3schools.com/tags/ref_urlencode.ASP

Also, I hope that wasn't your real password or you change it after :)