This blog will demonstrate the procedure of installing and setting up the PostgreSQL database on Ubuntu 22.04. Let’s get started.
For the purpose of installing PostgreSQL on Ubuntu 22.04, follow the given instructions.
Step 1: Update system packages
First of all, hit “CTRL+ALT+T” and update the system packages:
Step 2: Install PostgreSQL
Next, execute the provided command for the installation of PostgreSQL on Ubuntu 22.04:
Now move to the next step.
Step 3: Start PostgreSQL service
Write out the provided command for starting the PostgreSQL service:
Now, let’s head towards setting up the PostgreSQL database on Ubuntu 22.04.
Follow the below-given instructions for setting up the PostgreSQL database on Ubuntu 22.04.
Step 1: Switch to postgres account
The installation of PostgreSQL automatically created a user account named “postgres”. Switch to this account for accessing the PostgreSQL database:
Step 2: Create new role
After logging into the “postgres” account, create a new role with the help of the provided command:
Enter the role name and permit the new role to a super user. For instance, we have specified “linuxhint” as our new role name and entered “y” to mark this as a super user:
Step 3: Create PostgreSQL database
Now execute the “createdb” command and specify the same name for the PostgreSQL database which you have added as role name:
Step 4: Create a new user
Utilize the “adduser” command for creating a new user with the same name as the PostgreSQL role and database:
Step 5: Switch account
Next, switch to the newly created account by specifying the username in the following command:
Step 6: Connect to PostgreSQL database
Run the “psql” command for establishing a connection with the PostgreSQL database:
Step 7: Check connection information
Lastly, verify that you have connected to the PostgreSQL database:
The given output indicates that we have successfully connected to the created “linuxhint” PostgreSQL database:
To uninstall PostgreSQL database on Ubuntu 22.04, run the following command:
We have compiled the easiest method to install, set up, and uninstall PostgreSQL database on Ubuntu 22.04.
To install and set up the PostgreSQL database, firstly update the system packages and execute the “$ sudo apt install postgresql postgresql-contrib” command for PostgreSQL installation. Then, start the PostgreSQL service, switch to the “postgres” account, and create a new role, a database, and a new user. Then switch to the newly created account and run the “$ psql” command for connecting to the PostgreSQL database. This blog demonstrated the procedure of installing, setting up, and uninstalling the PostgreSQL database on Ubuntu 22.04.
Our latest Canonical website rebrand did not just bring the new Vanilla-based frontend, it also…
At Canonical, the work of our teams is strongly embedded in the open source principles…
Welcome to the Ubuntu Weekly Newsletter, Issue 873 for the week of December 29, 2024…
Have WiFi troubles on your Ubuntu 24.04 system? Don’t worry, you’re not alone. WiFi problems…
The following is a post from Mark Shuttleworth on the Ubuntu Discourse instance. For more…
I don’t like my prompt, i want to change it. it has my username and…