How to Install PostgreSQL on Ubuntu, Linux & Mac

Installation

$ sudo apt-get update
$ sudo apt-get install postgresql postgresql-contrib libpq-dev
$ sudo service postgresql start$ sudo -u postgres createuser --superuser $USER
$ sudo -u postgres createdb $USER
$ touch .psql_history
$ psql
$ brew install postgres
$ echo "export PGDATA=/usr/local/var/postgres" >> ~/.bash_profile
$ echo "export PGHOST=/tmp" >> ~/.bash_profile
$ source ~/.bash_profile
$ postgres
$ ln -sfv /usr/local/opt/postgresql/*.plist ~/Library/LaunchAgents
$ pg_ctl start
$ createdb $USER

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store