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

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

add key

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

and update

1
apt-get update

and install

1
apt-get install postgresql-10

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
~> 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中了。