2

In a terminal I do all, with all permissions by this simple command and no extra credentials:

psql postgres://postgres@localhost/myDB  # No password!! No other credentials!

That is: host=localhost, user=postgres, database=myDB.

So, how can I keep QGIS simple to connect with my local PostgreSQL instance?

Can I connect to QGIS using only it? Only host/user/database.


NOTES

  • I suppose that QGIS's community is mature (since 2002), and it needs and pushes for easy to use and simplicity...

  • I suppose that QGIS was created to be used with PostGIS... So I suppose that what I need is valid for all versions... But, if you need a reference, I am using QGIS v3+ with PostgreSQL v12+, psql version 12+ and PostGIS 3+.

  • Please, any simple solution, by terminal or by menu "Add Layer/PostgreSQL", with no password and no extra-credentials. This question/answer use password, so it is not a solution.

5
  • 5
    You shouldn't ever connect to a PostgreSQL database as postgres via QGIS. The admin login exists to allow you to create less privileged login roles and group roles for the actual security model that will be used for your project. Passwords are a way to prevent unauthorized access. psql stores passwords in a dotfile (in clear text!) to permit casual access. This is nearly enough to get PG banished from sites that take security seriously. pgAdmin4 addressed this with encypherment of the connection passwords. It seems this enhancement request is going is the other direction.
    – Vince
    Commented Jun 13, 2021 at 17:33
  • No @Vince, the question is not about env configuration, is about "how to do the same", in an environment where I am happy, no changes, no need for password. Commented Jun 13, 2021 at 17:56
  • 1
    Do you fully understand WHY your commandline works? How the authentication process of PostgreSQL works and why peer authentication is a thing? Why do you believe that giving a username/password ONCE (when setting up the connection) is not "simple"? Your question needs more details to get a good answer.
    – Tom
    Commented Jun 14, 2021 at 6:27
  • Hi @Tom, you and Vince are making a big mistake... Again, it is not an online server exposed to attacks from all internet, it is my personal desktop machine, on my house, and conecting database by localhost. So the authentication process is the login on my Linux machine. I use internet-banking, etc. I have local family photos, etc. so it is reliable for me and my personal PostgreSQL use. Commented Jun 30, 2021 at 22:52
  • @PeterKrauss Postgres has its own authentication process. Unless you set up peer authentication, your login does not automatically transfer to Postgres. I do a lot of dev work involving Postgres, and I've consistently found that user/pass with roles specified in the DB is more reliable than peer auth.
    – Tom
    Commented Jul 1, 2021 at 8:12

1 Answer 1

7

After you declared the database once like in screen capture and clicked OK, it's over. And yes, I don't use a password and it works out of the box (click on "Test Connection" if you doubt) Already too complex? You can't avoid declaring the connexion before using it. You may use pg_service.conf file approach (cf https://www.postgresql.org/docs/13/libpq-pgservice.html) otherwise and fill only the "Service" in the same panel as below screen capture.

enter image description here

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.