Postgresql Client Ubuntu

broken image


# To simplify the connection, let's use the default names cp ca-cert.pem root.crt cp client-cert.pem postgresql.crt cp client-key.pem postgresql.key # Set permissions chmod -R 600./ # Test the certificate openssl verify -CAfile root.crt postgresql.crt You can now connect to the remote server. After making changes in the Client Authentication configuration file, you will need to restart the PostgreSQL service. $ sudo systemctl restart postgresql Installing pgAdmin4 in Ubuntu. PgAdmin4 is not available in the Ubuntu repositories. We need to install it from the pgAdmin4 APT repository. Start by setting up the repository.

PostgreSQL is one of the popular, cross-platform, open-source object-relational database systems which is robust, high performing, and reliable with a strong community.

It dates back to 1986 as part of the POSTGRES project at the University of California, Berkeley, and carries 30 years of active development on its core platform. Its consistent performance over the years has proved its integrity, architecture, and extensibility for enterprise use. It is ACID-compliant and offers support for powerful addons like the popular PostGIS geospatial database extender.

We're going to cover the installation of PostgreSQL on common platforms in this article.

So let's get started.

Ubuntu

PostgreSQL is available for all flavors and versions of Ubuntu. You have got the choice to install and use the version available by default with your version of Ubuntu and supported for its lifetime or to use a specific version by adding the PostgreSQL repository and installing the same. We'll be covering both options here.

To use the default supported version provided by Ubuntu's repository, run:

PostgreSQL Apt Repository supports the current LTS versions of Ubuntu, i.e., 20.04, 18.04 and 16.04. Though it may not be fully supported, the same packages work on non-LTS versions as well by using the closest LTS version.

To use PostgreSQL apt repository, follow these steps:

To install a specific version from the PostgreSQL repository, instead of just postgresql which refers to the latest version, specify it like postgresql-12:

The repository also contains different packages, including third-party addons. For example, commonly available packages for version 12 of PostgreSQL includes:

postgresql-client-12client libraries and client binaries
postgresql-12core database server
postgresql-contrib-9.xadditional supplied modules (part of the postgresql-xx package in version 10 and later)
libpq-devlibraries and headers for C language frontend development
postgresql-server-dev-12libraries and headers for C language backend development
pgadmin4pgAdmin 4 graphical administration utility

Once installation completes, you can check the status of DB service by using the below command:

For Ubuntu, post-installation, the service should be enabled and running like:

CentOS

Like Ubuntu, RHEL/CentOS repositories also contain a specific version of PostgreSQL, which is supported through the lifetime for the OS. You can install the same using:

or you can use DNF if using CentOS 8.

Run below commands post-installation to initialize DB, enable the PostgreSQL service, and start it:

Or to use the packages directly from PostgreSQL yum repositories, we have to add the repository as:

And then to install a specific version of PostgreSQL like version 13, which is the latest stable release at the time of writing this article, use:

yum repository also contains additional packages for PostgreSQL, out of which some of the important ones are listed below:

postgresql-clientlibraries and client binaries
postgresql-servercore database server
postgresql-contribadditional supplied modules
postgresql-devellibraries and headers for C language development

Run below steps post-installation to initialize DB, enable the PostgreSQL service, and start it:

You can check the status of the DB service by using the below command:

Windows

Videoder. Windows 32-bit and 64-bit installers are available from the official PostgreSQL site here.

  • You can download the applicable binary based on the required version and architecture.
  • We'll be downloading the latest version available, which is v13.3 for Windows 64-bit platform. Once the download completes, launch the installer by double-clicking on it.
  • Click Next to proceed.
  • Click Next to continue with the default path or specify your custom installation path.
  • You can keep the default components selected and click Next to proceed.

Postgresql Client Ubuntu Download

  • Next, it asks for the data directory location; this can be kept as the default unless you have a separate dedicated disk or directory assigned for it. Click Next to proceed.
  • Specify a strong password that will be assigned to postgres user. Click Next when done.
  • Default port 5432 should be good for most cases. Click Next to go to the next page.
  • Select the locale for the DB and click Next to continue.
  • All the selected settings for the installation wizard will be listed for you to review and confirm. If anything needs to be changed, go back and change the same or click Next to proceed to the next page.
  • Setup will show that it's ready to proceed with the installation. When ready, click Next to start the installation.
  • Wait for the installation to complete. A confirmation will be shown for the same.
  • Once completed, you can uncheck Stack Builder and click Finish to exit from the installation wizard. Click on Start Menu and search for SQL Shell (psql) and click on its icon to open the psql shell.
  • SQL Shell (psql) opens up where you can interact with your PostgreSQL instance after specifying the connection details. All of the items can be selected as the default by simply pressing Enter except for the password, where you need to input the password specified for postgres user during the installation wizard. This will land you in postgres=# prompt.

Connect to PostgreSQL

Postgresql Client Ubuntu Install

Postgresql

A postgres user gets created automatically post-installation, which has superadmin access to the DB instance. On Linux, as a privileged user, you can switch to this account as:

Once in, we can reset postgres user password as:

And then launch PostgreSQL prompt with psqlas:

This will land you inside PostgreSQL prompt:

Pricewatcher 1 2 14 – monitor price changes online. At this prompt, you can interact with the database and do DB admin or user tasks. As a demo, the below steps create a DB and a user and then assign privileges to the new user to work on the new database:

We can then list the DBs using l command:

Now you can simply connect to a DB using:

Summary

Postgresql 9.6 Download

PostgreSQL is one of the widely adopted databases in the enterprise world because of its robustness, feature set, and scalability. It's easy to learn and tries to be compatible with SQL standards.

There's a tutorial available for PostgreSQL on its official site.

In this article, I will take you through the steps to install PostgreSQL on Ubuntu 20.04 LTS but before that let me ask you a question. Do you know which is the world's most advanced open source relational database ? If your answer is PostgreSQL then you are absolutely correct. It is one of the most advanced, powerful and open-source object-relational database system with high reliability, robustness, and performance features. It provides variety of features that help developers and administrators deploy their data-backed applications. We will see the steps to Install PostgreSQL Server in below section. More on official documentation.

How to Install PostgreSQL on Ubuntu 20.04 LTS

Also Read:8 Useful apt-add-repository command examples in Linux [Cheat Sheet]

Step 1: Prerequisites

a) You should have a running Ubuntu 20.04 LTS Server.

b) You should have sudo or root access to run privileged commands.

c) You should have apt or apt-get utility installed in Your Server.

d) You should also have wget, apt-key and mlocate utility available in your Server.

Step 2: Add Repository

As PostgreSQL packages are not available through Ubuntu repositories, we need to add the required repository configuration in /etc/apt/sources.list.d/pgdg.list from where we can download the PostgreSQL package by using below command.

Step 3: Import Repository Signing Key

Next, you need to import the repository signing key by downloading it through wget utility and adding it using apt-key command as shown below.

Step 4: Update Your Server

Once repository is added, you can now update the package cache with list of packages from repository by using apt-get update Mosaic pro 1 0 7. command as shown below.

Step 5: Install PostgreSQL

You can install the latest version of postgresql by running apt-get -y install postgresql command or you can install the specific version by running apt-get -y install postgresql-14 command.

Step 6: Check PostgreSQL Service

By default after installation, postgresql service will be started automatically. You can check the status by running /etc/init.d/postgresql status command. But in case it is not in active state, you can start or restart the service by using /etc/init.d/postgresql start or /etc/init.d/postgresql restart command.

Step 7: Check Postgres Version

There is a chance that postgres utility will not be available in the location where System usually look for all the binaries. So you might need to find the utility by using locate postgres command. In my system, it is installed under /usr/lib/postgres/14/bin directory. This path might be different for you. Once you located your package you can now run the utility by either specifying the entire path or adding this path in $PATH variable and then just use postgres command. For now I am using entire path to check the version of PostgreSQL Server currently installed by running /usr/lib/postgresql/14/bin/postgres -V command as shown below.

Step 8: Switch to psql prompt

PostgreSQL prohibits running any psql command through root user so in case you are currently logged in with root account, you need to switch it to a non-privileged account. You can switch to postgres user by running su - postgres command and then run psql command to start the postgres prompt as shown below.

Step 9: Show List of Databases

You can check the current list of databases by using l command in the PostgreSQL prompt as shown below.

Step 10: Check Your Database Connection

You can also check the current database connection details by using conninfo command in the PostgreSQL prompt.

Step 11: Create a Database

When it comes to database creation, you need to use create database syntax. In this example, we are creating a sample database by using CREATE DATABASE sample command and then checking the list by using l command.

Step 12: Uninstall PostgreSQL Database

Once you are done with the Database and you don't need it any longer then you can uninstall PostgreSQL Database by using apt-get -y remove postgresql command as shown below.





broken image