Error: "pq: database "gpadmin" does not exist" when running a GPDB script or tool
search cancel

Error: "pq: database "gpadmin" does not exist" when running a GPDB script or tool

book

Article ID: 296804

calendar_today

Updated On:

Products

VMware Tanzu Greenplum

Issue/Introduction

When trying to run a GPDB command such as gpmt, gpstate, gpstart, the command fails stating
database "gpadmin" does not exist

Example of a gpmt command 
[gpadmin@sl102276 ~]$ gpmt gp_log_collector -c 5 
Running gp_log_collector with arguments: "gpmt gp_log_collector -c 5" 
ERROR: Failed to populate gpdb array data 
ERROR: Log collection might have failed one or more hosts...
ERROR: Tool gp_log_collector 
Failed pq: database "gpadmin" does not exist


Environment

Product Version: 6.20

Resolution

The reason for this is the variable PGDATABASE is defaulted to the gpadmin DB. This DB can be dropped and no longer exists. So when the command runs, it tries to connect to the gpadmin DB. 

To overcome this we need to set the PGDATABASE to a DB that exists
export PGDATABASE=template1

Then rerun the GPDB command.