- How to Install PostgreSQL on Ubuntu 22.04
- Creating and Deleting a PostgreSQL Database on Ubuntu 16.04
- Listing and Switching Databases in PostgreSQL
PostgreSQL (pronounced “post-gress-Q-L”) is a household name for open source relational database management systems. Its object-relational meaning that you’ll be able to use objects, classes database schemas and in the query language. In this tutorial, we will show you how to install and connect to your PostgreSQL database on Ubuntu 16.04.
Step 1: Install PostgreSQL
First, we’ll obtain the authentication keys need to validate packages from the PostgreSQL repo.
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/ $(lsb_release -sc)-pgdg main" > /etc/apt/sources.list.d/PostgreSQL.list'
As a best practice, we will update our server before installing PostgreSQL.
apt-get -y update
After the update is complete, we’ll run the following command to install PostgreSQL
apt-get install postgresql-10
Step 2: Logging into PostgreSQL
Once installed, PostgreSQL creates a default user named “postgres”. This user works in a way different from that of other popular databases like MySQL. PostgreSQL users can change the method of authentication, but by default, it uses a mode called ident. Ident takes your OS username and compares it with the allowed database usernames.
You must first switch to the default Postgres user
su - postgres
You’ll now see that you are logged in as that user via the prompt change
Afterward, you can then enter the PostgreSQL terminal by typing:
You’ll know you are connected by the message below:
Type "help" for help.
Step 3: Logging out of PostgreSQL
To exit out of your PostgreSQL environment use the following command
- Using MySQL Command Line to Create a User
- How to Use Disk Quotas in Dedicated Linux Servers With cPanel
- How to Use Disk Quotas in Dedicated Linux Servers with Plesk
- Remove a MySQL User on Linux via Command Line
- Remove Permissions for a MySQL User on Linux via Command Line
- Grant Permissions to a MySQL User on Linux via Command Line
Our Sales and Support teams are available 24 hours by phone or e-mail to assist.