Reputation: 211
Im trying to create a database in postgresql using linux.
I connected to postgres with
sudo -u postgres psql postgres
postgres=# then i tried **CREATE DATABASE demo** or **createdb demo**
but none of them worked when i checked with \l command.
Any help ?
Upvotes: 11
Views: 31103
Reputation: 19
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
Upvotes: 2
Reputation: 663
first:
sudo su postgres
and then enter your password then type:
psql
and type this command:
CREATE DATABASE dbname;
Upvotes: 4
Reputation: 51649
sudo su - postgres
to become postgres
then psql -c "create database demo"
to create it from shell
Upvotes: 14