Install PostgreSql on Ubuntu16.04

as root, vim /etc/apt/sources.list.d/pgdg.list, and add:

deb http://apt.postgresql.org/pub/repos/apt/ xenial-pgdg main  

add key

wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc |apt-key add -  

and update

apt-get update  

and install

apt-get install postgresql-10  
~> su - postgres
Password:  
Last login: Wed Mar 1 13:19:02 CST 2017 on pts/1  
-bash-4.2$ psql
psql (9.2.18)  
Type "help" for help.

postgres=# create user xxf with password '******';  
CREATE ROLE  
postgres=# create database xxf owner xxf;  
CREATE DATABASE  
postgres=# grant all privileges on database xxf to xxf;  
GRANT  
postgres=# \q  
-bash-4.2$ exit
logout  
~> psql
psql (9.2.18)  
Type "help" for help.

xxf=>  

至此,就在数据库xxf中了。