PostgreSQL comes preinstalled on every Cloud9 workspace, yay! 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
Create a PostgreSQL database
Make sure you have logged into the PostgreSQL terminal and then you can just run:
postgres=# CREATE DATABASE "groceries";
List all databases
Connecting with your language of choice
First you must set a password for your postgres user.
postgres-# \password postgres
Enter new password:
Then you can connect with username “ubuntu” and the password you set. Here’s an example in PHP:
$link = pg_connect("host=localhost dbname=groceries user=ubuntu password=cloud9isawesome");