Help setting up postgresql


#1

I tried following the instructions in this link: Setting up PostgreSQL

I first enter: sudo service postgresql start in the terminal after which I see * Starting PostgreSQL 9.3 database server
…done.

The next step says to type psql to connect to the service, But when I type that into the command line, it says: psql: FATAL: role "ubuntu" does not exist

How can I fix this? Any help is appreciated, thank you.


#2

Use this command to connect to the service command line interface:

sudo sudo -u postgres psql


#3

Thank you! I was able to connect to the service. However, when I exit the service and try to create a database by typing: createdb sql_book it says: “createdb: could not connect to database template1: FATAL: role “ubuntu” does not exist”


#4

To create a database you have to enter the Postgresql Command Line with psql or the command from my post above.

Then create the database:

CREATE DATABASE "<name>";

Are you trying to set up Postgresql with Rails?


#5

Im just following a tutorial and learning how to create databases. It says that createdb is the same as CREATE DATABASE but is used on the command line and not used inside the psql console. However, when I just run the command createdb sql_book I get the error above. If I enter the psql console and type CREATE DATABASE sql_book; that works and creates the database.


#6

why are there 2 sudos in the command
?