Setup Postgresql On Ubuntu

Posted By Weston Ganger

First get latest postgresql info and install


sudo sh -c "echo 'deb http://apt.postgresql.org/pub/repos/apt/ $(lsb_release --codename | cut -f2)-pgdg main' > /etc/apt/sources.list.d/pgdg.list"
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
sudo apt-get update
sudo apt-get install postgresql postgresql-contrib libpq-dev

After this is done you can setup your user in psql:


# create psql superuser with current username
sudo -u postgres createuser --superuser $USER
sudo -u postgres psql

In the psql prompt set the password for the new user:

\password your-username

create a db with the name of the current user:

sudo -u postgres createdb $USER

Now you can connect to the database using just "psql" instead of having to type "psql postgres"


Related External Links:

Article Topic:Software Development - Linux

Date:April 26, 2014