美文网首页Postgresql
linux安装postgresql 12

linux安装postgresql 12

作者: 昵称违规 | 来源:发表于2020-06-23 14:19 被阅读0次

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

相关文章

网友评论

    本文标题:linux安装postgresql 12

    本文链接:https://www.haomeiwen.com/subject/ylchfktx.html