Install and Use PostgreSQL on Ubuntu 18.04 and 16.04



PostgreSQL, or Postgres, is a relational database management system that provides an implementation of the SQL querying language. It is a popular choice for many small and large projects and has the advantage of being standards-compliant and having many advanced features like reliable transactions and concurrency without reading locks. Installing PostgreSQL
$ sudo apt update
$ sudo apt install postgresql postgresql-contrib
The `postgres` user and then running `psql` to open the Postgres prompt.
$ sudo -u postgres psql
Creating a New Role
$ createuser --interactive

or

$ sudo -u postgres createuser --interactive
Creating a New Database
$ createdb databaseName

or 

$ sudo -u postgres createdb databaseName
Opening a Postgres Prompt with the New Role
$ sudo adduser sammy
Switch over and connect to the database by typing
$ sudo -i -u sammy
$ psql

Or,

$ sudo -u sammy psql
Check Connection Information
$ \conninfo
quit ot exit
$ \q
Setting a password for the `postgres` user
$ \password postgres
Selim Reza

Site Footer