postgresql
Install PostgreSQL from the distribution's packages, initialize it, and enable it at boot
- Command:
/go/postgresql - Category: Databases
- Required option: None
- Output: Package manager output
- Last updated: 2026-11-20
On this page: Overview · Quick start · Syntax · Options · Output · Examples · Troubleshooting · Details · See also
Overview
/go/postgresql installs the PostgreSQL database server and starts it. The service is also enabled, so it starts again after a reboot.
It installs the version that your operating system provides. It doesn't create databases or users. To do that, use postgre after the installation.
By default PostgreSQL accepts connections from the server itself only. This command doesn't change that.
Quick start
/go/postgresql
Syntax
/go/postgresql
The command takes no arguments. Run it as root.
Options
None.
Output
The command prints Installing PostgreSQL... and then the output of dnf or apt. It doesn't print a message when it finishes, and it doesn't check whether each step worked.
On an operating system that isn't listed in Details, it does nothing more.
Every run is logged to /var/log/go/postgresql.log with a timestamp and the arguments used.
Examples
# Install and start PostgreSQL
/go/postgresql
# Check that it is running and which version was installed
systemctl status postgresql
sudo -u postgres psql -c "select version();"
# Create a database and a user
/go/postgre
Troubleshooting
| Symptom | Likely cause | Fix |
|---|---|---|
Data directory is not empty! (AlmaLinux, Rocky, CentOS, Red Hat, Fedora) |
PostgreSQL was already initialized, for example by an earlier run. | Nothing to fix. The existing data is not touched. |
No match for argument: postgresql-server |
The distribution's repositories aren't enabled. | Enable the standard (AppStream) repository, then run the command again. |
FirewallD is not running |
The firewalld step failed because firewalld isn't the firewall in use. |
Ignore it. Open the port in your own firewall only if you need remote access (see allow). |
| The firewall port is still closed on AlmaLinux, Rocky, and so on | The rule is saved as permanent but not loaded. | Run firewall-cmd --reload. Note that the server still only listens on localhost. |
| You can't connect from another machine | PostgreSQL listens on localhost only, and pg_hba.conf doesn't allow other hosts. |
Change listen_addresses and pg_hba.conf, or better, connect through an SSH tunnel. |
psql: role "root" does not exist |
PostgreSQL has its own users. | Use sudo -u postgres psql. |
| The service doesn't start on AlmaLinux, Rocky, and so on | The initialization (postgresql-setup initdb) failed. |
Check journalctl -xeu postgresql. |
| Nothing happens | The operating system isn't supported. | Install PostgreSQL by hand. |
Details
| OS | What it does |
|---|---|
| AlmaLinux, Rocky, CentOS, Red Hat, Fedora | Installs postgresql-server and postgresql-contrib, runs postgresql-setup initdb, and uncomments port = 5432 in /var/lib/pgsql/data/postgresql.conf. Starts and enables postgresql. Adds the postgresql service to the public zone of firewalld (permanent only). Saves a copy of postgresql.conf as postgresql.bak the first time. |
| Debian, Ubuntu | Installs postgresql and postgresql-contrib. The package creates the first database cluster itself. Starts and enables postgresql. No firewall change. |
The configuration files are in /var/lib/pgsql/data/ on AlmaLinux, Rocky, CentOS, Red Hat, and Fedora, and under /etc/postgresql/ on Debian and Ubuntu.
| Item | Used for |
|---|---|
/go/function |
Shared helper functions, including the progress message. |
/usr/local/goadmio/linux/os.db |
The operating system. |
/var/log/go/postgresql.log |
The command log. |
See also
| Command | Description |
|---|---|
postgre |
Create, edit, or delete a PostgreSQL database and user |
postgresync |
Copy PostgreSQL data to a remote server |
pgloader |
Install PGLoader |
mariadb2postgre |
Convert a SQL file from MariaDB to PostgreSQL |
installmariadb |
Install or update MariaDB to the latest version |
dbls |
List all databases and their sizes |
allow |
Open a port in your server's firewall |