详细创建服务器步骤见第二章 Linux,关键步骤如下。
sudo vim /etc/apt/sources.list.d/pgdg.list
deb http://apt.postgresql.org/pub/repos/apt/ bionic-pgdg main
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
sudo apt update
sudo apt install postgresql-10
登录Postgresql
sudo -u postgres psql postgres
修改密码
ALTER ROLE postgres PASSWORD 'wxl1234' ;
创建新用户、新数据库
CREATE ROLE busuanzi WITH PASSWORD 'wxl123' LOGIN ;
CREATE DATABASE busuanzidb OWNER 'busuanzi';
退出
\q
修改postgresql.conf
sudo vim /etc/postgresql/10/main/postgresql.conf
修改内容如下
listen_addresses = '*'
修改pg_hba.conf
sudo vim /etc/postgresql/10/main/pg_hba.conf
修改内容如下
local all postgres md5
# TYPE DATABASE USER ADDRESS METHOD
# "local" is for Unix domain socket connections only
local all all md5
# IPv4 local connections:
host all all 127.0.0.1/32 md5
# IPv6 local connections:
host all all ::1/128 md5
host all all 192.168.56.0/0 md5
# Allow replication connections from localhost, by a user with the
# replication privilege.
local replication all peer
host replication all 127.0.0.1/32 md5
host replication all ::1/128 md5
重启postgresql服务
sudo service postgresql restart
jdbc:postgresql://192.168.56.110:5432/busuanzidb
开源、源码获取 https://github.com/lycheeman/big-data
内容来源于网络,如有侵权,请联系作者删除!