4

Does anyone know a way to save my username for PostGIS in QGIS, so I'll always be logged in without the need to enter my username and password everytime?

Anytime I start new project in QGIS, I need to log in and enter my username and my password and I wonder if there is any way that it will always be logged in and I'll not have to insert my username and password.

4
  • 2
    Is it PostGIS or QGIS or Postgis under QGIS ? Please be more explicit. Commented Aug 5, 2019 at 14:07
  • I saw the tags but for clarity and question referencing, it's not ideal. Commented Aug 5, 2019 at 14:40
  • Please add more details
    – Mapperz
    Commented Aug 5, 2019 at 15:58
  • I have edit it, I meant Postgresql in qgis. I'm bew to this so i'm sorry if it sounds confusing
    – ReutKeller
    Commented Aug 5, 2019 at 16:20

2 Answers 2

3

If you want to save the connection settings to your PostGresql database to avoid typing your password every time in Qgis.

You can use a pgpass configuration file : https://www.postgresql.org/docs/current/libpq-pgpass.html

it's a text file situated in your user space and you just need to type your login:password in this file. This file should exist in your installation (otherwise create it), you just need to edit it and add your login:password

NB : it's not safe to use it this way but it's ok if it's a local database.

1
  • thank you for the answer. I'm new to this. so I would love to know, what is the user space, how can I find it ? this text fille should cintain only the code as appaeard in that link with the correct data filled in this- hostname:port:database:username:password -and can I create it on notepad and then just put this text document in my user space?
    – ReutKeller
    Commented Aug 18, 2019 at 9:25
3

I found a better way, using QGIS 3.20.3.

On the left in the Browser Tab, click "Edit Connection" on the PostGIS Connection you want to save, and in the Popup under Authentication -> Configurations, create a new Authentication Configuration.

On a Mac, this prompted me to first set a Master Password, and then offered to save this Master Password in my KeyChain, so I don't even have to enter it when I start QGIS.

I did however have to delete and recreate the layer that was using this connection, as it kept asking me for the DB connection credentials every time I started QGIS. Once I recreated the layer it stopped asking me for that every time.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.