Tristan Tran
Tristan Tran

Reputation: 1513

Unable to create database in postgresql in ubuntu

I try to create a database. After reading around, I saw two methods:

Method 1:

xxxxxx:~$ sudo -i -u postgres
postgres$xxxx:~$ createdb mydb1

Method 2:

xxxxxx:~$ sudo -u postgres psql
postgres:# CREATE DATABASE mydb2

If I do method 1, the database mydb1 gets created. And when I am in postgres:# and do this \list, I can see mydb1 being listed. However, if I do method 2, after the end line above, there is no error whatsoever. But when I do \list in postgres:#, I don't the database mydb2 being listed.

My first time trying to set up a postgresql database. Please, if someone could explain what is going on.

Upvotes: 0

Views: 895

Answers (1)

Andronicus
Andronicus

Reputation: 26046

In psql you need to end the sql with the semicolon:

create database mydb2;

Upvotes: 2

Related Questions