select version();
SELECT pg_size_pretty(pg_database_size(current_database())) as size;
service postgresql status
Show current activity...
postgres=# \x auto
Expanded display is used automatically.
postgres=# SELECT * from pg_stat_activity ;
As 'root'...
service postgresql start
service postgresql restart
As 'postgres'...
requires $PGDATA to be setecho $PGDATA
/var/lib/pgsql/data
pg_ctl start
As 'root'...
service postgresql stop
As 'postgres'...
requires $PGDATA to be setecho $PGDATA
/var/lib/pgsql/data
pg_ctl stop -m fast
or
pg_ctl stop -m immediate
PostgreSQL's fast option is equivalent to Oracle's immediatePostgreSQL's immediate option is equivalent to Oracle's abort !!!su - postgres
psql
psql -h hostname -U username -d dbname
--Locally as postgres
cd /var/lib/pgsql/data
cp postgresql.conf postgresql.conf.20190103
vi postgresql.conf
listen_addresses = '*' <---------------- by default is listen_addresses = 'localhost'
--Locally as root (restart PostgreSQL instance)
service postgresql stop
service postgresql start
--Locally as postgres
psql
postgres=# SHOW listen_addresses;
listen_addresses
------------------
*
postgres=# SHOW hba_file;
hba_file
---------------------------------
/var/lib/pgsql/data/pg_hba.conf
--Locally as postgres
cd /var/lib/pgsql/data
cp pg_hba.conf pg_hba.conf.20190103
vi pg_hba.conf <-------------- add following lines to pg_hba.conf
# 2019-01-03 Allow remote connections if the user's password is correctly supplied.
# TYPE DATABASE USER ADDRESS METHOD
host all all 0.0.0.0/0 md5
host all all ::/0 md5
--Locally as root (restart PostgreSQL instance)
service postgresql stop
service postgresql start
List databases...
\l
Connect to database...
\c databasename
List tables, views and sequences...
\d