Postgres (SQL) - Install Postgres on Linux
by
Jeremy Canfield |
Updated: June 04 2023
| Postgres (SQL) articles
On a Debian distribution (Mint, Ubuntu), the apt-get install command can be used. On a Red Hat distribution (CentOS, Fedora, Red Hat), the dnf install or yum install command can be used.
dnf install postgresql-server
Then use the postgressql-setup initdb command to initialize the database.
~]$ sudo postgresql-setup initdb
Initializing database ... OK
You should now be able to start and enable the service.
sudo systemctl start postgresql
sudo systemctl enable postgresql
The psql --list command can be used to list the databases.
~]$ sudo -u postgres psql --list
List of databases
Name | Owner | Encoding | Collate | Ctype | Access privileges
-----------+----------+----------+-------------+-------------+-----------------------
postgres | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 |
template0 | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/postgres +
| | | | | postgres=CTc/postgres
template1 | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/postgres +
| | | | | postgres=CTc/postgres
Did you find this article helpful?
If so, consider buying me a coffee over at