Murwan eisa
Murwan eisa

Reputation: 171

Databases in psql Don't Show up in PgAdmin4

I installed Postgres

image

and followed the instruction. I create a database and logged in by the master password but I don't find the database even the + mark is not shown in the servers. can anyone help, please?

Upvotes: 15

Views: 23168

Answers (3)

Jindrich Vavruska
Jindrich Vavruska

Reputation: 830

In case you created your database as template CREATE DATABASE ... IS_TEMPLATE =true, then the database is considered as "system object" and is not shown in the list if PgAdmin4 option "Show system objects?" is set to false.

Try menu File -> Preferences, in the tree find Browser -> Display, and the option is at the bottom.

Another possible way is to remove the template option:

ALTER DATABASE xxx IS_TEMPLATE = false

and then you will see your database without changing PgAdmin preferences.

Upvotes: 4

joedragons
joedragons

Reputation: 2645

I followed the introductory advice from @MwamiTovi but I still did not have an option to create a server as he noted. However, I was able to get my databases to appear by clicking menu option Object -> Register -> Server and type in the information (hostname/address, port) from my associated psql setup.

This was using PG Admin 4.19 on macOS Big Sur.

Upvotes: 1

MwamiTovi
MwamiTovi

Reputation: 2522

Unlike in pgAdmin3, with pgAdmin4,
here you have to manually connect to a running postgres server and
you already have your specific database (DB) created.

So to set the stage, make sure you have the postgres server is running, and that you have created that DB already too.

Creating the database and grant privileges using CLI

Notice (in the image) that I CREATE database XYZ and GRANT all privileges to default user postgres. (Note; to work properly with pgAdmin4, you have to create a user called postgres in order to be able to connect with and log in to pgAdmin4.)

Then here are some quick steps to follow:

  1. When within pgAdmin4, right-click the Servers option and select create.

Note:

  • In the image you'll see (1) next to "Servers" because I have done this process already. Kindly ignore that).
  • Select "server group" if you have many servers that you want to better manage. For most basic use cases, go ahead and select "server" (like I did).

Initialize process to create a server


  1. For either option you select above, you'll get a pop-box to complete the "connection process". I selected "server" which is appropriate for your use case (see image below).

Note:

  • "name" field is required
  • As you can see already, enter a name (I went with "postgres" since it's what I was used to by default in pgAdmin3, but you can enter any name).
  • Notice the "connect now" checkbox is checked by default so as soon as the process is successful, your DB should display in the sidemenu. (This is a key to confirm that you entered the right info). But you can always uncheck this, to connect later.

Enter the server name


  1. Now, click connection tab and you see the image below.
    The key fields to fill here, to keep it simple, are host name/address and password. Remember to save after entering your info.

Note:

  • If on connecting to local machine, localhost or http://127.0.0.1 should do. (I did "localhost")
  • If connecting to a DB instance in the cloud e.g. AWS, enter the endpoint in the host space.
    Here's more from AWS
  • A lot of the other fields have the default settings used when installing postgres and pgAdmin.

Enter the host name/address and user password


If you followed the steps above properly, then you should see something like this after you save.

This is the "sign of victory"


Here's a good guide from the pgAdmin documentation

Upvotes: 29

Related Questions