Tuesday, December 13, 2022

PostgreSQL Installation on Ubuntu (2022 Dec 13)

Contents of install_postgresql.sh

sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list' wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add - sudo apt-get update sudo apt-get -y install postgresql Ref: postgresql.org $ bash install_postgresql.sh

Find the file "pg_hba.conf"

(base) ashish@ashish-Lenovo-ideapad-130-15IKB:~/Desktop$ locate pg_hba.conf /etc/postgresql/15/main/pg_hba.conf /home/ashish/anaconda3/pkgs/libpq-12.9-h16c4e8d_3/share/pg_hba.conf.sample /home/ashish/anaconda3/share/pg_hba.conf.sample /usr/share/postgresql/15/pg_hba.conf.sample

Edit the file "pg_hba.conf"

$ sudo nano /etc/postgresql/15/main/pg_hba.conf $ sudo cat /etc/postgresql/15/main/pg_hba.conf ... # Database administrative login by Unix domain socket local all postgres md5 # TYPE DATABASE USER ADDRESS METHOD # "local" is for Unix domain socket connections only local all all trust

Test the installed DB

$ sudo -i -u postgres postgres@ashish-Lenovo-ideapad-130-15IKB:~$ psql psql (15.1 (Ubuntu 15.1-1.pgdg22.10+1)) Type "help" for help. postgres=# \du List of roles Role name | Attributes | Member of -----------+------------------------------------------------------------+----------- postgres | Superuser, Create role, Create DB, Replication, Bypass RLS | {} postgres=# postgres=# SELECT CURRENT_DATE ; current_date -------------- 2022-12-13 (1 row) postgres=# select version(); version ----------------------------------------------------------------------------------------------------------------------------- PostgreSQL 15.1 (Ubuntu 15.1-1.pgdg22.10+1) on x86_64-pc-linux-gnu, compiled by gcc (Ubuntu 12.2.0-3ubuntu1) 12.2.0, 64-bit (1 row)
Tags: Technology,Database,

No comments:

Post a Comment