Install PostgreSQL 16 on Ubuntu 2204
# dependencies sudo apt update -y sudo apt install gnupg2 wget vim -y # 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' curl -fsSL https://www.postgresql.org/media/keys/ACCC4CF8.asc|sudo gpg --dearmor -o /etc/apt/trusted.gpg.d/postgresql.gpg sudo apt update -y sudo apt install postgresql-16 sudo apt install postgresql-contrib libpq-dev #if you want to run Ruby on Rails psql -v # should say 16 sudo systemctl enable postgresql sudo systemctl start postgresql sudo systemctl status postgresql
sudo -u postgres psql CREATE USER myuser WITH PASSWORD 'myPassword'; # if you want him to be superuser ALTER USER myuser WITH SUPERUSER; # if you just want him to be able to create DB ALTER USER myuser WITH CREATEDB;
Source