Find the Best Cosmetic Hospitals

Explore trusted cosmetic hospitals and make a confident choice for your transformation.

โ€œInvest in yourself โ€” your confidence is always worth it.โ€

Explore Cosmetic Hospitals

Start your journey today โ€” compare options in one place.

postgresql Installation and Configuration Tutorial Guide

How To Install and Use PostgreSQL on Ubuntu?

Step 1 โ€” Installing PostgreSQL


$ sudo apt update
$ sudo apt install postgresql postgresql-contrib
$ sudo systemctl start postgresql.service

Step 2 โ€” Using PostgreSQL Roles and Databases

The installation procedure created a user account called postgres that is associated with the default Postgres role. In order to use Postgres, you can log into that account.


Switch over to the postgres account on your server by typing:

$ sudo -i -u postgres

You can now access a Postgres prompt immediately by typing:
$ psql

This will log you into the PostgreSQL prompt, and from here you are free to interact with the database management system right away.

Exit out of the PostgreSQL prompt by typing:
> \q
This will bring you back to the postgres Linux command prompt.

Accessing a Postgres Prompt Without Switching Accounts
$ sudo -u postgres psql
> \qCode language: JavaScript (javascript)

Step 3 โ€” Creating a New Role

Currently, you just have the postgres role configured within the database. You can create new roles from the command line with the createrole command. The –interactive flag will prompt you for the name of the new role and also ask whether it should have superuser permissions.


Currently, you just have the postgres role configured within the database. You can create new roles from the command line with the createrole command. 

The --interactive flag will prompt you for the name of the new role and also ask whether it should have superuser permissions.

If you are logged in as the <strong>postgres </strong>account, you can create a new user by typing:
$ createuser --interactive

If, instead, you prefer to use sudo for each command without switching from your normal account, type:
$ sudo -u postgres createuser --interactive
Output
Enter name of role to add: sammy
Shall the new role be a superuser? (y/n) yCode language: PHP (php)

Step 4 โ€” Creating a New Database

Another assumption that the Postgres authentication system makes by default is that for any role used to log in, that role will have a database with the same name which it can access.

This means that, if the user you created in the last section is called sammy, that role will attempt to connect to a database which is also called โ€œsammyโ€ by default. You can create the appropriate database with the createdb command.

If you are logged in as the postgres account, you would type something like:
$ createdb sammy.

If, instead, you prefer to use sudo for each command without switching from your normal account, you would type:
$ sudo -u postgres createdb sammy

Step 5 โ€” Opening a Postgres Prompt with the New Role

To log in with ident based authentication, youโ€™ll need a Linux user with the same name as your Postgres role and database.

If you donโ€™t have a matching Linux user available, you can create one with the adduser command. You will have to do this from your non-root account with sudo privileges (meaning, not logged in as the postgres user):


$ sudo adduser sammy

Once this new account is available, you can either switch over and connect to the database by typing:

$ sudo -i -u sammy
psql
Or, you can do this inline:
$ sudo -u sammy psql

<strong>If you want your user to connect to a different database, you can do so by specifying the database like this:</strong>

psql -d postgres
Once logged in, you can get check your current connection information by typing:

\conninfo
Output
You are connected to database "sammy" as user "sammy" via socket in "/var/run/postgresql" at port "5432".
This is useful if you are connecting to non-default databases or with non-default users.Code language: PHP (php)

Find Trusted Cardiac Hospitals

Compare heart hospitals by city and services โ€” all in one place.

Explore Hospitals
Iโ€™m a DevOps/SRE/DevSecOps/Cloud Expert passionate about sharing knowledge and experiences. I have worked at <a href="https://www.cotocus.com/">Cotocus</a>. I share tech blog at <a href="https://www.devopsschool.com/">DevOps School</a>, travel stories at <a href="https://www.holidaylandmark.com/">Holiday Landmark</a>, stock market tips at <a href="https://www.stocksmantra.in/">Stocks Mantra</a>, health and fitness guidance at <a href="https://www.mymedicplus.com/">My Medic Plus</a>, product reviews at <a href="https://www.truereviewnow.com/">TrueReviewNow</a> , and SEO strategies at <a href="https://www.wizbrand.com/">Wizbrand.</a> Do you want to learn <a href="https://www.quantumuting.com/">Quantum Computing</a>? <strong>Please find my social handles as below;</strong> <a href="https://www.rajeshkumar.xyz/">Rajesh Kumar Personal Website</a> <a href="https://www.youtube.com/TheDevOpsSchool">Rajesh Kumar at YOUTUBE</a> <a href="https://www.instagram.com/rajeshkumarin">Rajesh Kumar at INSTAGRAM</a> <a href="https://x.com/RajeshKumarIn">Rajesh Kumar at X</a> <a href="https://www.facebook.com/RajeshKumarLog">Rajesh Kumar at FACEBOOK</a> <a href="https://www.linkedin.com/in/rajeshkumarin/">Rajesh Kumar at LINKEDIN</a> <a href="https://www.wizbrand.com/rajeshkumar">Rajesh Kumar at WIZBRAND</a> <a href="https://www.rajeshkumar.xyz/dailylogs">Rajesh Kumar DailyLogs</a>

Related Posts

Top 10 No-Code Platforms Tools in 2026: Features, Pros, Cons & Comparison

Introduction In 2026, no-code platforms have become essential for businesses and individuals looking to build powerful applications, websites, and automations without the need for programming knowledge. These…

Read More

Top 10 AI Training Data Platforms Tools in 2026: Features, Pros, Cons & Comparison

Introduction In 2026, AI training data platforms have become the backbone of successful machine learning (ML) and artificial intelligence (AI) projects. These platforms streamline the process of…

Read More

Top 10 AI Poster & Flyer Design Tools in 2026: Features, Pros, Cons & Comparison

Introduction In 2026, AI-powered poster and flyer design tools have revolutionized the way businesses, marketers, educators, and creators produce visually stunning promotional materials. These tools leverage artificial…

Read More

Top 10 Collaboration Platforms Tools in 2026: Features, Pros, Cons & Comparison

Introduction In 2026, collaboration platforms are more essential than ever. As remote and hybrid work environments continue to thrive, having the right collaboration tool can be the…

Read More

The 5 Most Popular Email APIs Among Developers In 2026

In the modern world, where everything is going digital, email is among the most important means of communication both in personal and business life. As a developer,…

Read More

Top 10 Construction Management Software Tools in 2026: Features, Pros, Cons & Comparison

Introduction Construction Management Software (CMS) has become indispensable in 2026 for efficiently handling various aspects of construction projects, ranging from budgeting, scheduling, resource allocation, project tracking, to…

Read More
Subscribe
Notify of
guest
0 Comments
Newest
Oldest Most Voted
0
Would love your thoughts, please comment.x
()
x