It looks like you're new here. If you want to get involved, click one of these buttons!
Sign In RegisterIt looks like you're new here. If you want to get involved, click one of these buttons!
PostgreSQL (Postgres) is an open-source general-purpose object-relational database management system with numerous advanced capabilities that allows you to build fault-tolerant systems or complex applications.
In this tutorial, you will see how you can install PostgreSQL on Ubuntu 20.04.
sudo apt update
sudo apt install postgresql postgresql-contrib
sudo systemctl start postgresql.service
sudo -i -u postgres
psql
It will log you into the PostgreSQL prompt, and you will be able to interact with the database management system.
To exit out of the PostgreSQL prompt, you can use this command:
\q
createuser --interactive
Then you will need to enter the name of the new role and make the role as superuser.
This implies that if the user you established in the previous section is named, for example, test, the role will attempt to connect to a database named test by default. The createdb command can be used to construct the necessary database.
If you're logged in as the postgres account, you can use this command:
createdb test
If you want to use sudo for each command without switching from your normal account, you can use the following command:
sudo -u postgres createdb test
If you don't have a matching Linux user, use the adduser command to create one. You must do the following using a non-root account with sudo access (not as the postgres user):
sudo adduser test
sudo -i -u sammy
psql
psql -d postgres
\conninfo