1、更新系统:
sudo apt-get update
sudo apt-get upgrade
2、安装 curl ca-certificates gnupg
sudo apt-get install curl ca-certificates gnupg
3、添加官方提供的key
curl https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
4、再更新一下:
sudo apt-get update
sudo apt-get upgrade
5、安装:
sudo apt-get install postgresql-12
6、检查 PostgreSQL 是否正在运行:
service postgresql status
7、登录账户:
sudo su postgres
psql
8、修改密码
ALTER USER postgres WITH PASSWORD 'my_password';
9、创建用户
CREATE USER my_user WITH PASSWORD 'my_password';
10、赋予权限
ALTER USER my_user WITH SUPERUSER;
11、删除用户
DROP USER my_user;
12、创建用户
CREATE ROLE odoo WITH LOGIN SUPERUSER CREATEDB CREATEROLE INHERIT REPLICATION CONNECTION LIMIT -1 PASSWORD '123456';
13、查看用户
\du
14、退出
\q
15、开启远程连接
sudo vim /etc/postgresql/10/main/postgresql.conf
listen_addresses = '*'(# listen_addresses = '*'前添加,60行)
sudo vim /etc/postgresql/10/main/pg_hba.conf
host all all 0.0.0.0/0 md5(# IPv4 local connections后添加,96行)
16、重启数据库
sudo service postgresql restart