linux安装postgresql 12

1、 yum install -y https://download.postgresql.org/pub/repos/yum/12/redhat/rhel-8.12-x86_64/pgdg-redhat-repo-latest.noarch.rpm

2、yum -y install postgresql12

3、yum -y install postgresql12-server

4、/usr/pgsql-12/bin/postgresql-12-setup initdb

5、systemctl enable postgresql-12

6、systemctl start postgresql-12

7、su - postgres


#切换用户后,提示符变更为“-bash-4.2$”;

#同时数据库中也会生成一个名为”postgres”的数据库用户,且密码已自动生成;

#PostgreSQL在数据库用户同名的系统账号下登录免密;

psql -U postgres

#进入数据库后修改密码;

postgres=# alter user postgres with password 'postgre';

\q 退出

exit 退出


这是外部是不能访问的

8、找到pg_hba.conf  一般在/var/lib/pgsql/12/data下


#在第82行之后,”IPv4 local connections”下新增允许的客户端;

host all all 0.0.0.0/0 md5

9、 允许远程访问

#默认配置文件在/var/lib/pgsql/12/data/下postgresql.conf

#修改listen_addresses = 'localhost'为listen_addresses = '*',允许所有远程访问;

10、设置环境变量

进入配置文件 /etc/profile ,增加环境变量

export PATH=$PATH:/usr/pgsql-12/bin

11、重启服务

systemctl restart postgresql-12

©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

友情链接更多精彩内容