Search code examples
databasepostgresqlpgadmin

How do I connect to postgres database that do not use password with pgadmin3..?


I have a postgres database that I set up with SQLAlchemy, with this code:

SQLALCHEMY_DATABASE_URI = "postgresql:///mydb"

And now I want to manage my database with pgAdmin3, but I'm confused because don't know how to connect it with the username and password form is blank, like this:

enter image description here

there is the OK button was inactive.

before, I know how to connect it if there I set up my username and password in my SQLAlchemy configuration:

SQLALCHEMY_DATABASE_URI = "postgresql:///myuser:mypassword@localhost/mydb"

and if the SQLALCHEMY_DATABASE_URI like that, I can connect with pgAdmin3 like this: enter image description here

so, how to connect pgAdmin3 with my postgres database if I set up it with no username and password..?

Note: this just for my local.


Solution

  • There is no connection without a username. If "postgresql:///mydb" successfully connects to mydb, the username might be taken from your environment variable $PGUSER. Otherwise it defaults to your system (OS) username.

    You can find your username with SELECT current_user (From SQLAlchemy). Then use this to connect with PgAdmin3.

    As for the password: Your server might be configured to not require a password. Or you have a password in your ~/.pgpass file (or the file referenced by $PGPASSFILE). These will be used by PgAdmin3 as well.