1. 程式人生 > 實用技巧 >PostGreSQL資料庫安裝

PostGreSQL資料庫安裝

一、下載

二、解壓

  tar -zxvf壓縮包

三、建立pgsql使用者並設定密碼

  

  建立使用者和密碼都為postgres

四、建立pgsql資料目錄,並給postgres使用者授權

  建立目錄:pgsql

  

  使用者授權:chown postgres pgsql_data

  

五、初始化

  切換使用者postgre

  

  初始化資料庫

  

六、啟動資料庫

  按照上面提示命令啟動資料庫

  

七、檢視程序

  

  pgsql的預設埠:5432

八、連線資料庫

  

九、修改配置檔案設定可遠端訪問

  

  也可單獨設定某個ip可訪問

  0.0.0.0/0 代表所有 ip 都可以訪問。設定完需要重啟資料庫才能生效

啟動服務:/opt/develop/pgsql/bin/pg_ctl -D /opt/develop/pgsql/pgsql_data/ -l logfile start

停止服務:/opt/develop/pgsql/bin/pg_ctl -D /opt/develop/pgsql/pgsql_data/ -l logfile stop