1, add apt source file:
Create /etc/apt/sources.list.d/pgdg.list. The distributions are called codename-pgdg. In the example, replace squeeze with the actual distribution you are using:
deb http://apt.postgresql.org/pub/repos/apt/ wheezy-pgdg main(You may determine the codename of your distribution by running lsb_release -c.)
Import the repository key from https://www.postgresql.org/media/keys/ACCC4CF8.asc, update the package lists, and start installing packages:
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add - sudo apt-get update
2,install postgresql
3, Change the default password of postgresql. The default user of postgresql is postgres,
(1), root@somemachine:~# sudo -u postgres psql
(2), postgres=# ALTER USER
postgres WITH PASSWORD 'postgres';
4, change linux password:
root@somemachine:~#sudo -u postgres passwd
5, change the postgresql configuration files, make it can accessible from remote client:
Add fellow consent:
# to allow your client visiting
postgresql server
host all all 0.0.0.0 0.0.0.0
md5
or:
or:
host all all 0.0.0.0/0 md5
root@somemachine:~# sudo -u postgres psql -U postgresorroot@somemachine:$ psql -U postgrespsql (9.0.3)Type "help" for help.postgres=# update pg_database set datallowconn = TRUE where datname = 'template0';UPDATE 1postgres=# \c template0You are now connected to database "template0".template0=# update pg_database set datistemplate = FALSE where datname = 'template1';UPDATE 1template0=# drop database template1;DROP DATABASEtemplate0=# create database template1 with template = template0 encoding = 'UTF8';CREATE DATABASEtemplate0=# update pg_database set datistemplate = TRUE where datname = 'template1';UPDATE 1template0=# \c template1You are now connected to database "template1".template1=# update pg_database set datallowconn = FALSE where datname = 'template0';UPDATE 17, create database:1.create users
postgres=# create user “zhaofeng” with password ‘123456’ nocreatedb;2.create database with special user postgres=# create database “testdb” with owner=”zhaofeng”; 4.shell managment: root@somemachine:~# -u postgres createuser -D -P test1 root@somemachine:~# -u postgres createdb -O test1 db1 8,Install postgisapt-get install postgresql-9.3-postgis-2.19,enable postgis and postgresql extensions:psql -d yourdatabase -c "CREATE EXTENSION postgis;" psql -d yourdatabase -c "CREATE EXTENSION postgis_topology;" psql -d yourdatabase -c "CREATE EXTENSION fuzzystrmatch;" psql -d yourdatabase -c "CREATE EXTENSION postgis_tiger_geocoder;"10 import sql datapostgres@wemet:/$ psql -d kct -f /opt/kct.sql