系統:
[root@weianvrgv /]# cat /etc/redhat-release
CentOS Linux release 8.2.2004 (Core)
安裝中文字符集
[root@weianvrgv /]#yum install glibc-common
[root@weianvrgv /]#yum install -y langpacks-zh_CN
設置中文字符
[root@weianvrgv /]#vi /etc/locale.conf
LANG="zh_CN.utf8"
安裝PostgreSQL數據庫(centos8默認安裝的是10版本)
[root@weianvrgv /]#yum install postgresql*
切換用戶
[root@weianvrgv /]#su - postgres
初始化
/usr/bin/postgresql-setup initdb
退出postgres用戶
exit
編輯數據庫配置文件
[root@weianvrgv /]#vi /var/lib/pgsql/data/postgresql.conf
listen_addresses = '*'
[root@weianvrgv /]#vi /var/lib/pgsql/data/pg_hba.conf
大約在83行添加
host all all 0.0.0.0/0 md5
啟動數據庫
[root@weianvrgv /]#systemctl restart postgresql
切換用戶
[root@weianvrgv /]#su - postgres
登錄數據庫
[postgres@weianvrgv ~]$psql
修改postgres密碼
ALTER USER postgres WITH PASSWORD 'postgres';
退出
\q
退出postgres用戶
[postgres@weianvrgv ~]$exit
重啟數據庫
[root@weianvrgv /]#systemctl restart postgresql
現在PostgreSQL數據庫可以遠程登錄,用戶名:postgres 密碼:postgres