mathz.nu Asterisk Blacklist Hobby webbhotell

2015/05/19

Postgres on Ubuntu 14.04

Filed under: Postgresql,Server — Mathz @ 15:26

Install postgres 9.4
Add source
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt trusty-pgdg main" >> /etc/apt/sources.list'

add key
wget --quiet -O - http://apt.postgresql.org/pub/repos/apt/ACCC4CF8.asc | sudo apt-key add -

update
sudo apt-get update

install
sudo apt-get install postgresql-9.4-postgis-2.1 pgadmin3 postgresql-contrib

Add user
# sudo su - postgres
$ createdb mydb
$ psql -s mydb
# create user someuser password 'somepassword';
# GRANT ALL PRIVILEGES ON DATABASE mydb TO someuser;

Enable PostGIS

#sudo su - postgres
#psql
CREATE EXTENSION postgis;
CREATE EXTENSION postgis_topology;
CREATE EXTENSION fuzzystrmatch;
CREATE EXTENSION postgis_tiger_geocoder;

To verify
\dx postgis*

Restore backup
psql database < file

Nice to know commands

mysql: SHOW TABLES
postgresql: \d
postgresql: SELECT table_name FROM information_schema.tables WHERE table_schema = 'public';

mysql: SHOW DATABASES
postgresql: \l
postgresql: SELECT datname FROM pg_database;

mysql: SHOW COLUMNS
postgresql: \d table
postgresql: SELECT column_name FROM information_schema.columns WHERE table_name ='table';

mysql: DESCRIBE TABLE
postgresql: \d+ table
postgresql: SELECT column_name FROM information_schema.columns WHERE table_name ='table';

1 Comment »

  1. After going over a number of the blog articles on your website,
    I truly appreciate your technique of blogging.
    I book marked it to my bookmark website list and will be checking back
    in the near future. Please check out my web site too and let me know how you
    feel.

    Comment by politie in beeld — 2016/02/24 @ 17:23

RSS feed for comments on this post. TrackBack URL

Leave a comment

Powered by WordPress