postgresql使用命令行创建实例,用户并连接

[[email protected] person]# su - postgres
Last login: Tue Sep 15 11:33:23 CST 2020 on pts/0
-bash-4.2$ psql
psql (9.6.5)
Type "help" for help.


postgres=# create user wsj with password 'wsj';
CREATE ROLE
postgres=# create database wsjdb owner wsj;
CREATE DATABASE
postgres=# grant all privileges on database wsjdb to wsj;
GRANT
postgres=# \q
-bash-4.2$ exit
logout
 

创建完数据库,用户之后,连接数据库,使用dbeaver连接数据库失败。

postgresql使用命令行创建实例,用户并连接

 

考虑一下,可能是远程访问需要设置:

../pgsql/data/postgresql.conf文件中要有如下配置,确认无误,还是连不上:

postgresql使用命令行创建实例,用户并连接

再考虑一下,可能是端口填写的不对,查询pg库的端口号:

[[email protected] data]# netstat -a | grep PGSQL
unix  2      [ ACC ]     STREAM     LISTENING     26832    /tmp/.s.PGSQL.5432
unix  2      [ ACC ]     STREAM     LISTENING     26830    /var/run/postgresql/.s.PGSQL.5432

postgresql使用命令行创建实例,用户并连接