PostgreSQL Ubuntu

PostgreSQL import database

Postgres login (localhost):

sudo -u postgres psql

Postgres login (external host):

psql -h EXTERNAL_HOST_IP -d DB_NAME -U postgres

Listing databases:

postgres=# \l

Switching databases:

postgres=# \c DB_NAME

Listing tables:

DB_NAME=# \dt

Creating database, user and adding access on PostgreSQL

Create a new database:

postgres=# create database DB_NAME;

Create a new database user:

postgres=# create user USER_NAME with encrypted password 'USER_PASSWORD';

Grant access on database for the user

postgres=# grant all privileges on database DB_NAME to USER_NAME

PostgreSQL import database:

sudo -u POSTGRESQL_USER psql -h HOST_IP  -d DB_NAME < SQL_FILE.sql

Leave a Reply

Your email address will not be published. Required fields are marked *