xxxxxxxxxx
# Step 1 — Installing PostgreSQL
sudo apt update
sudo apt install postgresql postgresql-contrib
sudo systemctl start postgresql.service
# Step 2 — Creating a New Role
sudo -u postgres createuser --interactive --pwprompt
# Step 3 - Accessing
sudo -u postgres psql
# connection string
# https://linuxhint.com/understand-postgres-connection-string/
postgers://localhost
#If a username and a password are needed, the updated URI looks like this:
postgres://<username>:<password>@localhost
xxxxxxxxxx
# from the official postgresql site: https://www.postgresql.org/download/linux/ubuntu/
# this will install the latest version of the postgresql.
# Create the file repository configuration:
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
# Import the repository signing key:
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
# Update the package lists:
sudo apt-get update
# Install the latest version of PostgreSQL.
# If you want a specific version, use 'postgresql-12' or similar instead of 'postgresql':
sudo apt-get -y install postgresql
xxxxxxxxxx
# It's fairly simple to setup:
first install postgres from:
https://www.postgresql.org/download/
then install pgadmin4:
https://www.pgadmin.org/download/
after everything installed properly,
# follow this step:
# go to etc/postgresql/14/main --(assuming your version is 14)
# open terminal in this folder and type
# if nano not installed install first.. it's so good.
sudo nano pg_hba.conf
# repalce all method from peer/md5/ to trust like this
local all all trust
local all all trust
host all all 127.0.0.1/32 trust
host all all a::1/128 trust
ctrl + s
ctrl + x
# then run
sudo service postgresql restart
# then type
sudo -u postgres psql
# after that, type
ALTER USER postgres WITH PASSWORD 'postgres'
# now exit out of it by typing
\q
# now run again
sudo service postgresql restart
# That's all you have to do, congrats, everything will work now.