linux环境下安装postgresql

PostgreSQL: Linux downloads (Red Hat family)postgresql官网

PostgreSQL: Linux downloads (Red Hat family)

环境:

centos7

postgresql14

选择版本

linux环境下安装postgresql_第1张图片

 执行启动命令

linux环境下安装postgresql_第2张图片

配置远程连接文件

vi   /var/lib/pqsql/14/data/postgresql.conf 

 这里将listen_addresses值由localhost改成*号。

linux环境下安装postgresql_第3张图片

配置秘钥方式

vi /var/lib/pgsql/14/data/pg_hba.conf

在末尾添加

host    all             all              0.0.0.0/0              md5 

 如果不加使用navicat连接时会提示如下错误

linux环境下安装postgresql_第4张图片

 使用命令行操作postgresql

登录postgresql

su - postgres

使用内置的用户 postgres

创建一个新用户及数据库

create user root with password '密码';

create database 库名 owner root;

给用户授权

grant all privileges on database 库名 to root;

查看已经创建的数据库

\l

linux环境下安装postgresql_第5张图片

查询角色属性

给账号绑定角色

GRANT postgres TO root;

退出postgresql

\q

退出当前的 shell

exit

navicat测试连接

linux环境下安装postgresql_第6张图片

linux环境下安装postgresql_第7张图片

查找文件所在的路径

find / -name pg_hba.conf

你可能感兴趣的:(postgree,linux,运维,服务器)