Skip to content

Instantly share code, notes, and snippets.

@superjojo140
Created December 4, 2019 09:56
Show Gist options
  • Save superjojo140/2a0221d517f356965371b3969f37b29f to your computer and use it in GitHub Desktop.
Save superjojo140/2a0221d517f356965371b3969f37b29f to your computer and use it in GitHub Desktop.
Setup local PostgreSQL and pgAdmin on ArchLinux

Working with local PostgreSQL and pgAdmin on ArchLinux

Daily Usage

Start postgreSQL

$ sudo systemctl start postgresql

Stop postgreSQL

$ sudo systemctl stop postgresql

Starting pgAdmin

$ pgadmin4

Initital Setup

Install packages

$ sudo pacman -S postgresql pgadmin4

Setup postgresql

PostgreSQL automatically creates a new system user called postgres. Most of the PostgreSQL commands must be executed by this user. Commands that should be run as the postgres user are prefixed by [postgres]$ in this article. You can switch to this user with:

$ sudo -iu postgres

After installing the package you have to init the database cluster (execute as postgres user):

[postgres]$ initdb -D /var/lib/postgres/data

You can now exit to your local user by:

$ exit

Now start the postgreSQL Database with:

$ sudo systemctl start postgresql

If you want postgreSQL to start automatically on system boot also type:

$ sudo systemctl enable postgresql

Add a new database user (execute as postgres):

$ sudo -iu postgres  
[postgres]$ createuser --interactive -P

The -P flag creates a user with a password

Usefull Links:

https://wiki.archlinux.org/index.php/PostgreSQL


Using pgAdmin

Run pgAdmin by selecting the apllication from your launcher or type:

$ pgadmin4

Make sure the PostgreSQL Server is running. You can see the server's log messages (including the port number, which will be neccessary later on) in systemd's log. Access the log with:

$ journalctl -e

Exit the journal by pressing q


Add your PostgreSQL server to pgAdmin

Now add the PostgreSQL Server in the pgAdmin Control Panel by clicking on "Add New Server".

Give your server configuration a name.

Under the "Connection" Tab set the following properties

  • Use 127.0.0.1 (localhost) as Hostname
  • The port, your server is listening on. (By default this is 5432)
  • Use postgres as Maintenance database
  • The username and password of the PostgeSQL user you created so far

If this is a lucky day everything should work now!

Copy link

ghost commented Oct 24, 2023

use sudo

@ProgrammingLife
Copy link

Where is the pgadmin now? There is no nor in pacman, neither in aur.

@Vricap
Copy link

Vricap commented Aug 3, 2024

pgadmin is gone from arch repository :(

@YassirEH
Copy link

YassirEH commented Aug 8, 2024

pgadmin is gone from arch repository :(

have you found an alternative way for it?

@Vricap
Copy link

Vricap commented Aug 8, 2024

pgadmin is gone from arch repository :(

have you found an alternative way for it?

I haven't tried it, but there's a web based alternative on AUR called phpPgAdmin: https://wiki.archlinux.org/title/PhpPgAdmin

@YassirEH
Copy link

YassirEH commented Aug 9, 2024

I haven't tried it, but there's a web based alternative on AUR called phpPgAdmin: https://wiki.archlinux.org/title/PhpPgAdmin

i used their python package here, yes it is more of a hassle than an AUR package but at least you won't risk it breaking or touching anything, works pretty well too

@Apok01
Copy link

Apok01 commented Dec 29, 2024

THANKS

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment