[gdal-dev] Issues specifying PostGIS connection details - possibly related to special characters in passwords?

Robin Wilson robin at rtwilson.com
Tue Jul 2 09:13:42 PDT 2024


Hi,

Hmm, I’m sure I tried escaping it before - but putting a \ in front of it fixed it - obviously I didn’t try properly before. Possibly I only tried quoting it in various ways. Thanks for the solution!

Now the thing I’m intrigued about is why it was working with the postgresql:// connection string but not the PG connection string…

Best regards,

Robin

On 2 July 2024 at 17:08:18, Daniel Evans (daniel.fred.evans at gmail.com) wrote:

Hi Robin,

Is this a shell issue, rather than a GDAL one? The dollar sign makes me suspect that a Unix shell is interpreting "robin$42" as "the string 'robin' and the value of variable $42" before it gets into GDAL. My terminal would interpret it as the following:
$ echo robin$42
robin

and I'd need to escape the dollar symbol to get the text verbatim:
$ echo robin\$42
robin$42

Cheers,
Daniel

On Tue, 2 Jul 2024 at 16:35, Robin Wilson via gdal-dev <gdal-dev at lists.osgeo.org> wrote:
Hi,

I’m using ogr2ogr to load a GeoPackage file into a PostGIS database. I initially tried using a command like this:

ogr2ogr --debug ON -f PostgreSQL PG:"host=<IP> user=<user> password=robin$42 dbname=data sslmode=require" file.gpkg -nln table_name

However, this doesn’t work, and I always get an error:

FATAL:  password authentication failed for user “<user>"

If I restructure the command to use the alternative postgresql:// connection string like this, then it works:

ogr2ogr --debug ON -f PostgreSQL 'postgresql://<user>:robin$42@<IP>/data?sslmode=require’ file.gpkg -nln table_name

I don’t remember running into this problem before when connecting to PostGIS databases using the PG: connection string, so I’m wondering whether my shell is doing something strange with my password? Obviously I don’t want to share my actual password, but it has a $ in it, and I wonder whether somehow this is causing problems - but only when using the PG: connection string.

Any suggestions welcome,

Best regards,

Robin


Dr Robin Wilson
www.rtwilson.com

_______________________________________________
gdal-dev mailing list
gdal-dev at lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/gdal-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20240702/4aaa5bee/attachment-0001.htm>


More information about the gdal-dev mailing list