RedHat/CentOS8【PostgreSQL13】源代碼編譯、安裝和配置

1. 安裝依賴包

[centos@host ~]$ sudo dnf install gcc gcc-c++ epel-release clang libicu-devel perl-ExtUtils-Embed readline readline-devel zlib zlib-devel openssl openssl-devel pam-devel libxml2-devel libxslt-devel openldap-devel systemd-devel tcl-devel bzip2


2. 下載軟件

[centos@host ~]$? wget https://ftp.postgresql.org/pub/source/v13.1/postgresql-13.1.tar.bz2


3. 解壓并安裝

[centos@host ~]$? tar -jxvf postgresql-13.1.tar.bz2

[centos@host ~]$? ./configure --prefix=/usr/local/pgsql

[centos@host ~]$? make

[centos@host ~]$? sudo make install


4. 添加用戶并更改權限

[centos@host ~]$? useradd postgres

[centos@host ~]$? passwd postgres

[centos@host ~]$? mkdir -p /data/pgsql/{data,log}

[centos@host ~]$? touch /data/pgsql/log/pgsql.log

[centos@host ~]$? chown -R postgres:postgres /data/pgsql


5. 添加環(huán)境變量

[centos@host ~]$? vi /etc/profile

export PGHOME=/usr/local/pgsql

export PGDATA=/data/pgsql/data

export PATH=$PGHOME/bin:$PATH

:wq

使之生效

[centos@host ~]$? source /etc/profile


6. 初始化數(shù)據(jù)

[centos@host ~]$? su postgres

[postgres@host ~]$? cd /usr/local/pgsql/bin/

[postgres@host ~]$? ./initdb -D /data/pgsql/data


7. 配置文件說明

pg_hba.conf? 是訪問控制配置文件;

postgresql.conf? 是postgresql的主配置文件。


8. 修改pg_hba.conf文件

將該文件中的IPV4的連接修改為

# IPv4 local connections:

host all all 0.0.0.0/0 trust

##表示信任來自所有id連接的客戶端


9.修改postgresql.conf配置文件

將 localhost 改為 *,表示監(jiān)聽所有的網(wǎng)絡連接。其他的參數(shù)保持默認即可。

listen_addresses = '*'


10. 啟動數(shù)據(jù)庫

[postgres@host ~]$? cd /usr/local/pgsql/bin/

[centos@host ~]$ ./pg_ctl -D /data/pgsql/data -l /data/pgsql/log/pgsql.log start


11.停止數(shù)據(jù)庫

[centos@host ~]$? pg_ctl -D /data/pgsql/data/ -l /data/pgsql/log/pgsql.log stop


12. 登錄數(shù)據(jù)庫并設置密碼

[postgres@host ~]$? cd /usr/local/pgsql/bin/

[centos@host ~]$? ./psql

postgres=# \password

Enter new password:

Enter it again:

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

postgres=# \q

最后編輯于
?著作權歸作者所有,轉載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務。

相關閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容