Postgresql not creating db with “createdb” as superuser, yet not outputting errors

Damien Roche picture Damien Roche · Nov 10, 2012 · Viewed 60.2k times · Source

I am working with a fresh postgresql install, with 'postgres' super user. Logged in via:

sudo -u postgres psql


postgres=# createdb database
postgres-# \list
                                  List of databases
   Name    |  Owner   | Encoding |  Collation  |    Ctype    |   Access privileges   
-----------+----------+----------+-------------+-------------+-----------------------
 postgres  | postgres | UTF8     | en_GB.UTF-8 | en_GB.UTF-8 | 
 template0 | postgres | UTF8     | en_GB.UTF-8 | en_GB.UTF-8 | =c/postgres
                                                             : postgres=CTc/postgres
 template1 | postgres | UTF8     | en_GB.UTF-8 | en_GB.UTF-8 | =c/postgres
                                                             : postgres=CTc/postgres

No errors, yet table is not being created. Any ideas?

Answer

Saddam Abu Ghaida picture Saddam Abu Ghaida · Nov 10, 2012

createdb is a command line utility which you can run from bash and not from psql. To create a database from psql, use the create database statement like so:

create database [databasename];

Note: be sure to always end your SQL statements with ;