一、創建psotgres用戶
groupadd postgres
useradd -g postgres postgres
二、創建必須目錄
下載路徑https://www.enterprisedb.com/download-postgresql-binaries
wget https://get.enterprisedb.com/postgresql/postgresql-9.6.4-1-linux-x64-binaries.tar.gz
進入下載目錄
tar -xzf postgresql-9.6.4-1-linux-x64-binaries.tar.gz -C /data/service
創建data目錄:
mkdir -p /data/service/postgresql/data
mkdir -p /data/service/postgresql/log
授權:
chown -R postgres.postgres pgsql (解壓目錄)
chown -R postgres.postgres postgresql
三、初始化
cd /data/service/pgsql/
su postgres
./bin/initdb -E utf8 -D /data/service/postgresql/data
四、啟動
./postgres -D /data/service/postgresql/data/ > /data/service/postgresql/log/postgres.log &
關閉
./pg_ctl -D /data/service/postgresql/data stop
登錄
./psql -U pg -d mydb
----------------------
遠程連接
1 修改pg_hba.conf文件
host all all 127.0.0.1/32 trust
host all all 192.168.1.0/24 md5
其中,數字24是子網掩碼,表示允許192.168.1.0--192.168.1.255的計算機訪問!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。