Create the file /etc/apt/sources.list.d/pgdg.list and add a line for the repository
deb http://apt.postgresql.org/pub/repos/apt/ xenial-pgdg main
Import the repository signing key, and update the package lists
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
sudo apt-get update
sudo apt-get install postgresql-10
sudo apt-get install pgadmin4
Check your password file
cat /etc/passwd
See here line like
postgres:x:26:26:PostgreSQL Server:/var/lib/pgsql:/bin/bash
Check the file path after : here is /var/lib/pgsql
open the file pg_hba.conf for Ubuntu it will be in /etc/postgresql/10/main and change this line:
local all postgres peer
to
local all postgres trust
Restart the server
sudo service postgresql restart
Login into psql and set your password
psql -U postgres
ALTER USER postgres with password '123456';
Finally change the pg_hba.conf from
local all postgres trust
to
local all postgres md5
After restarting the postgresql server, you can access it with your own password
Now when you go to prompt of psql
psql -U postgres it will ask password
-----------------------
Now adding this with pgadmin4
Add new server
give some name to server
hostname: localhost
port: 5432
db: postges
username: postges
password: 123456 - just added
deb http://apt.postgresql.org/pub/repos/apt/ xenial-pgdg main
Import the repository signing key, and update the package lists
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
sudo apt-get update
sudo apt-get install postgresql-10
sudo apt-get install pgadmin4
Check your password file
cat /etc/passwd
See here line like
postgres:x:26:26:PostgreSQL Server:/var/lib/pgsql:/bin/bash
Check the file path after : here is /var/lib/pgsql
open the file pg_hba.conf for Ubuntu it will be in /etc/postgresql/10/main and change this line:
local all postgres peer
to
local all postgres trust
Restart the server
sudo service postgresql restart
Login into psql and set your password
psql -U postgres
ALTER USER postgres with password '123456';
Finally change the pg_hba.conf from
local all postgres trust
to
local all postgres md5
After restarting the postgresql server, you can access it with your own password
Now when you go to prompt of psql
psql -U postgres it will ask password
-----------------------
Now adding this with pgadmin4
Add new server
give some name to server
hostname: localhost
port: 5432
db: postges
username: postges
password: 123456 - just added
No comments :
Post a Comment