Start postgreSQL
$ sudo systemctl start postgresqlStop postgreSQL
$ sudo systemctl stop postgresqlStarting pgAdmin
$ pgadmin4$ sudo pacman -S postgresql pgadmin4PostgreSQL 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 postgresAfter installing the package you have to init the database cluster (execute as postgres user):
[postgres]$ initdb -D /var/lib/postgres/dataYou can now exit to your local user by:
$ exitNow start the postgreSQL Database with:
$ sudo systemctl start postgresqlIf you want postgreSQL to start automatically on system boot also type:
$ sudo systemctl enable postgresqlAdd a new database user (execute as postgres):
$ sudo -iu postgres
[postgres]$ createuser --interactive -PThe
-Pflag creates a user with a password
https://wiki.archlinux.org/index.php/PostgreSQL
Run pgAdmin by selecting the apllication from your launcher or type:
$ pgadmin4Make 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 -eExit the journal by pressing
q
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
postgresas Maintenance database - The username and password of the PostgeSQL user you created so far
If this is a lucky day everything should work now!
Hey there,
thanks so much for this guide. It probably saved me hours of research. A few things i ran into that one should mention:
1.
If you execute the command:
[postgres]$ initdb -D /var/lib/postgres/dataand run into the following error:Make sure your System is up to date. The error might disappear magically.
2.
Make sure to open a new Terminal after executing
$ pgadmin4, since it will block the current Terminal.