Using pgAdmin to manage your bots PostgeSQL database
Note, this article assumes you are using docker to run your application as per the How do I run my app? article.
Initial steps
-
Start your application if it is not already running
docker-compose up -d
-
After a few moments, the docker containers should start, one of which is running pgAdmin. Before connecting to pgAdmin, you will need to know the port number it is listening on.
docker-compose ps
Doing so will show you the running containers, one of which is pgAdmin (in this case, the third one)
Name Command State Ports ------------------------------------------------------------------------------------------------- a086_client_1 docker-entrypoint.sh sh -c ... Up a086_db_1 docker-entrypoint.sh postgres Up 5432/tcp a086_pgAdmin_1 /entrypoint.sh Up 443/tcp, 80/tcp, 0.0.0.0:9091->9090/tcp a086_server_1 sh -c dotnet new tool-man ... Up 0.0.0.0:8001->5000/tcp
-
Under the “ports” column for the “pgAdmin” container, look for the entry which contains
0.0.0.0:xxxx
. In this case, it is0.0.0.0:9091
(Please note that different bots may use different ports) This indicates that we can access pgAdmin on port 9091 of the local host. (eg http://localhost:9091)
Logging in
- Open your browser to the URL you determined above (eg http://localhost:9091) and you will be presented with a login screen.
-
The credentials for the login screen can be found in the
docker-compose.yml
file in the root of your repository. Specifically, look for thePGADMIN_DEFAULT_EMAIL
andPGADMIN_DEFAULT_PASSWORD
environment variables. -
If this is your first time logging in to pgAdmin, you will need to add the connection to your application’s PostgreSQL server, otherwise you can skip these steps.
-
Before you proceed, you will need to know the credentials to the PostgreSQL database. This can be found in the
docker-compose.yml
file in the root of your repository. Specifically, look for thePOSTGRES_DB
,POSTGRES_USER
, andPOSTGRES_PASSWORD
environment variables. -
Click “Add New Server”
-
On the first tab (General), give your connection a name. This can be anything you like, though we recommend using the name of your application
-
On the second tab (Connection), fill in the following fields, then click the
Save
buttonHost name/address: db Maintenance database: [the value of the POSTGRES_DB environment variable from step 3a above] Username: [the value of the POSTGRES_USER environment variable from step 3a above] Password: [the value of the POSTGRES_PASSWORD environment variable from step 3a above] Save Password: Checked/Ticked
-
-
Your connection should now show up on in the left-hand menu. If it doesn’t automatically connect (little red cross on the connection), you can click on the connection and it should initiate the connection
-
You should now be connected to your PostgreSQL database and can manage the database, tables, data, etc.
For further information on how to use pgAdmin, head over to pgAdmin’s website and check out the official documentation
Was this article helpful?