Setting up PostgreSQL

postgresql

#1

PostgreSQL comes preinstalled on every Cloud9 workspace, yay! :tada: Here are a few basic commands to help out. The sudo sudo in each command is not a typo, you need to enter this or it will prompt for your ubuntu user password and break.

Start the PostgreSQL service

sudo service postgresql start

Connect to the service

psql

Create a PostgreSQL database

Make sure you have logged into the PostgreSQL terminal and then you can just run:

psql
postgres=# CREATE DATABASE "groceries";

List all databases

psql
postgres=# \list

Connecting with your language of choice

First you must set a password for your postgres user.

psql
postgres-# \password postgres
Enter new password: 

Then you can connect with username “ubuntu” and the password you set. Here’s an example in PHP:

<?php
$link = pg_connect("host=localhost dbname=groceries user=ubuntu password=cloud9isawesome");
?>

Related


Setting Up phpPgAdmin
Problems with postgreSQL in ruby
Postgresql: is there a pre-set database cluster? Do I need initdb?
Trouble connecting Postgresql to Rails
Can't connect to Phppgadmin
PostgreSQL and node
Tutorials - Table of Contents
Help setting up postgresql
PostgreSQL & Django
Migrate existing Rails project from SQLite3 to PostgreSQL for Heroku production
#2

A post was split to a new topic: Start Postgres automatically


#3

in what port is PostgreSQL running? Thanks.


#4

How am I able to connect node.js to PostgreSQL in cloud9. Am I to make a change in the IP as I did with mongoDB?
I am able to run the same package with PostgreSQL outside of cloud9, so I don’t believe it is a config issue.

[HPM] Proxy created: /api -> http://localhost:3000
Frontend located at http://localhost:8080/
events.js:141
throw er; // Unhandled ‘error’ event
^

Error: listen EADDRINUSE 0.0.0.0:8080
at Object.exports._errnoException (util.js:907:11)
at exports._exceptionWithHostPort (util.js:930:20)
at Server._listen2 (net.js:1250:14)
at listen (net.js:1286:10)
at net.js:1395:9
at nextTickCallbackWith3Args (node.js:453:9)
at process._tickDomainCallback (node.js:400:17)


#6

Isn’t there a way to run this automatically everytime system is started.


#7

I’m trying to set up postgeSQL on AWS Cloud9, but I’m running into an error when starting the service:

postgresql: unrecognized service

Did something change from the time of the post to now on how to start the service?


#8

Did someone get “postgresql: unrecognized service” fixed?


#9

Hi I am also experiencing the “postgresql: unrecognized service” issue on AWS Cloud 9.

I tried to follow the following instructions but without success:

https://wiki.postgresql.org/wiki/YUM_Installation


#10

Has anyone figured out a solution to this?


#11

In case anyone has the same problem as me in the future, it was just a simple service name issue.

I used the following command to find out what the postgres service is called:
ls /etc/init.d | grep postgres
Then executed:
sudo service <service_name> start