PostgreSQL, Software Development

Log In As Different User To pgAdmin 4 Web UI

This post shows how to log in as a different user to pgAdmin 4 UI via a web browser. Also, it will help you sleep better at night! The idea is to create another logical server and use another user.

PostgreSQL and PgAdmin Docker Containers

Depending on our situation, we may need PostgreSQL and PgAdmin instances running to try out this guide. We may not have permissions to create new users in our shared development database. Should we need first to set up both PostgreSQL and PgAdmin quickly, we can start with Docker containers. The PostgreSQL user will be turreta instead of postgres. Then, come back here and log in as another user.

The Problem – Cannot Log In As Different User

Let us say that we are new to PostgreSQL and made it through the installation process without any issue. We also installed pgAdmin 4 and used the user Postgres login role credentials.

We successfully logged in but later decided to use other user credentials instead. At first sight, doing that is not possible in pgAdmin 4 web UI. But if we look closer, we can create multiple logical servers in pgAdmin 4, each with different user credentials.

Create Another User

Before we can log in as a different user, we need to create another user with proper credentials. Consider the following command, which creates another superuser login role. A login role in PostgreSQL is synonymous with the user. So, when we create a login role, we create a user.  For this post, we create a user mydev with a “password” password. We will use this user credential to log in as another user in pgAdmin.

Then, we use mydev to log in instead of the postgres role. But we cannot change the “connection settings” because the fields related to connections are not editable.

Log in as a different user

To log in as a different user to pgAdmin, we need to create another logical server – it is a connection configuration. On the left side of the browser window, create a new server under the Servers icon. Then, we can fill in with different user credentials.

Bottom Line

The bottom line is to create another logical server in the pgAdmin 4 with another name to avoid name-conflict with existing connection configurations. Then, log in using another user, and we are done! That is how we can log in as a different user to pgAdmin!

Loading

Got comments or suggestions? We disabled the comments on this site to fight off spammers, but you can still contact us via our Facebook page!.


You Might Also Like