PostgreSQL is an open source, SQL-based, relational database manager that emphasizes security and SQL compliance.
According to the PostgreSQL website, it is “The World’s Most Advanced Open Source Relational Database”. Powerful and fast, PostgreSQL is often presented as the logical choice in complex systems or where advanced clustering is required.
An interesting feature of PostgreSQL is the multiversion concurrency control. This method adds an image of the database state to each transaction offering great performance advantages.
Is it as advanced as it is claimed to be?
Well, yes, it is. One of the most compelling reasons to use it is that its high concurrency can serve many clients at the same time and deliver the same information from its tables, without blocking.
On the other hand, with PostgreSQL, you can forget about the data problem because it has support for multiple data types natively.
For this and many more reasons, is that many people consider it an enterprise database manager with the advantage of being free and having an open license.
Install PostgreSQL on Ubuntu 22.04
PostgreSQL is available in the official Ubuntu 22.04 repositories. This makes the installation process simple and fast. Let’s go.
Open your terminal or establish a connection to your server via SSH. When you do so, update the system.
sudo apt update
sudo apt upgrade
Thereafter, you can install the PostgreSQL related packages.
sudo apt install postgresql postgresql-contrib
You will be able to manage PostgreSQL using the systemctl
command and thus start it, stop it or check the status.
For example, to start it
sudo systemctl start postgresql.
To stop it:
sudo systemctl stop postgresql
To apply configuration changes, you will have to learn how to restart it:
sudo systemctl restart postgresql
Finally, you can check the status of the service:
sudo systemctl status postgresql
Accessing the PostgreSQL console
PostgreSQL’s administration is different from others like MySQL. The first thing is that during installation, a user named postgres
has been created who has access to the console.
So to access the console, we have to change the user.
sudo -i -u postgres
And now you can access with this command.
psql
Inside it, you can create a database and start working.
To exit this:
\q
The normal thing is that you begin creating a new user. You can do it this way:
createuser --interactive
Enter name of role to add: imaginelinux
Shall the new role be a superuser? (y/n) y
Conclusion
Thanks to this post, now you know how to install PostgreSQL on Ubuntu 22.04, and it is a great help for your projects or systems.
I hope you liked this post and help us to share it.