PostgreSQL源码安装

PostgreSQL源码安装,第1张

概述PostgreSQL 源码安装 下载PostgreSQL安装包 wget https://ftp.postgresql.org/pub/source/v9.5.7/postgresql-9.5.7.tar.gz 官网下载 https://www.postgresql.org/ftp/source/ 安装依赖包 yum -y install  readline-devel zlib-devel  解


Postgresql 源码安装


下载Postgresql安装包


wget @R_403_6822@s://ftp.postgresql.org/pub/source/v9.5.7/postgresql-9.5.7.tar.gz


官网下载

@R_403_6822@s://www.postgresql.org/ftp/source/


安装依赖包

yum -y install readline-devel zlib-devel


解包-配置-编译-安装

tar -xf postgresql-9.5.7.tar.gz

cd postgresql-9.5.7

./configure --prefix=/usr/local/postgresql

make && make install


默认超级用户(root)不能启动postgresql

useradd postgres

mkdir -p /data/postgresql/data

mkdir -p /data/postgresql/data/log

chown -R postgres:postgres /usr/local/postgresql/

chown -R postgres:postgres /data/postgresql/data/


为了方便,设置postgres环境变量

su - postgres //切换到postgres用户

[postgres@localhost ~]$ vim .bash_profile

#.bash_profile#Getthealiasesandfunctionsif[-f~/.bashrc];then.~/.bashrcfi#UserspecificenvironmentandstartupprogramsPGHOME=/usr/local/postgresql#psql安装目录exportPGHOMEPGDATA=/data/postgresql/data#数据库目录exportPGDATAPATH=$PATH:$HOME/bin:$HOME/.local/bin:$PGHOME/binexportPATH


source ./.bash_profile 使其立即生效


[postgres@localhost ~]$ which psql

/usr/local/postgresql/bin/psql

[postgres@localhost ~]$ psql -V

psql (Postgresql) 9.5.7


初始化数据库

initdb

Success. You can Now start the database server using: pg_ctl -D /data/postgresql/data -l logfile start


启动Psql

pg_ctl -D /data/postgresql/data -l /data/postgresql/data/log/postgres.log start


设置Postgresql密码,

[postgres@localhost data]$ psql

psql (9.5.7)

Type "help" for help.

postgres=# \password

Enter new password: //密码

Enter it again: //确认密码


修改Postgresql密码

[postgres@localhost data]$ psql

Password:

psql (9.5.7)

Type "help" for help.

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

ALTER RolE

postgres=# \q


默认psql本地登录是不需要密码的,即使我们设置了密码,也不需要密码就能登录。应为配置文件pg_hba.conf中的local设置为trust,为了安全我们修改为 password,就是使用密码才能登陆,(当我们忘记密码的时间,也可以使用这用方式,先设置为trust之后,修改密码,然后在设置为password。)


[postgres@localhost ~]$cd /data/postgresql/data

[postgres@localhost data]$ vim pg_hba.conf

localallallpassword#默认trust,本地登录不要密码,设置为password使用密码登录。hostallall0.0.0.0/0password#ip地址修改为0.0.0.0/0,


修改psql默认端口

[postgres@localhost data]$ vim postgresql.conf

Listen_addresses='*'#127.0.0.1只允许本地访问,设置为*允许整个网络。port=5432#监听端口


修改后需要重启psql才能生效


pg_ctl -D /data/postgresql/data -l /data/postgresql/data/log/postgres.log restart

总结

以上是内存溢出为你收集整理的PostgreSQL源码安装全部内容,希望文章能够帮你解决PostgreSQL源码安装所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/sjk/1172052.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-06-02
下一篇2022-06-02

发表评论

登录后才能评论

评论列表(0条)

    保存