create database in postgresql with bash command create database in postgresql with bash command bash bash

create database in postgresql with bash command


sudo su - postgres to become postgres

then psql -c "create database demo" to create it from shell


first:

    sudo su postgres

and then enter your passwordthen type:

     psql

and type this command:

    CREATE DATABASE dbname;


simple type on bash

$ createdb -U postgres(db user) dbname

if set hba_config in pg for access to db in network type

$ createdb -h YOUR_IP -U postgres(db user) dbname

if you set password for db user pg ask your password to create database