CentOS7下安裝PostgreSQL12


使用yum命令添加PostgreSQL軟件源

yum install https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm

使用yum命令安裝PostgreSQL

yum install postgresql12
yum install postgresql12-server
yum install postgresql12-contrib

初始化數據庫

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

配置開機啟動與啟動

systemctl enable postgresql-12
systemctl start postgresql-12

切換到postgres用戶。然后執行修改用戶密碼SQL語句。其中“postgres”為要修改密碼的用戶,“123456”為用戶的密碼

su - postgres
psql -c "alter user postgres with password '123456'"

配置遠程訪問

vi /var/lib/pgsql/12/data/postgresql.conf
將“#listen_addresses = ‘localhost’”改為“listen_addresses = ‘*’

打開並編輯文件“/var/lib/pgsql/12/data/pg_hba.conf”。在文件的末尾添加“host all all 0.0.0.0/0 md5”

重啟服務

systemctl  restart postgresql-12

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM