PostgreSQL 15 install : Ubuntu

by Mark Nielsen
Copyright June 2022


Just basic install and Python.
  1. Links
  2. Install


Links



Install

sudo sh -c 'echo "deb https://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-15

sudo systemctl status postgresql

echo "select version() " | sudo -iu postgres psql

echo "CREATE USER mark WITH PASSWORD 'mark';" | sudo -iu postgres psql
echo " ALTER USER postgres PASSWORD 'mark'" | sudo -iu postgres psql 
echo " create database mark;" | sudo -iu postgres psql

echo " ALTER DATABASE mark OWNER TO mark" | sudo -iu postgres psql


# This will fail.
export PGPASSWORD=mark
psql -U mark

# This will work
psql -U mark -h 127.0.0.1 -c "create table test1 (i int);"

echo "select * from pg_settings where name in ('port'); " | sudo -iu postgres psql