postgre 的安裝步驟

來源:互聯網
上載者:User
  1 . 為 了安全考 慮 , Postgresql 不能以 root 用 戶 運行,所以必 須 建立 對應 的用 戶 和 組 。 # useradd postgre (自動建立 postgre 組,必須為root許可權)   2. 安裝的 過 程
  解壓到 /usr/local/src:
  # tar xvfz Postgresql 8.0.1.tar.gz
  # cd Postgresql -8.0.1
  # ./configure --prefix=/usr/local/pgsql
  # make
  # make install
  # chown -R postgre.postgre /usr/local/pgsql   3. 用 vi ~postgre/.bash_profile   命令編輯檔案 添加 : PGLIB=/usr/local/pgsql/lib
   PGDATA=$HOME/data
   PATH=$PATH:/usr/local/pgsql/bin
   MANPATH=$MANPATH:/usr/local/pgsql/man
   export PGLIB PGDATA PATH MANPATH   4 . 以 postgres 用 戶 登 錄 ,
    # su – postgre
   建立資料 庫 目 錄 :
   $ mkdir data 啟動資料庫引擎    $  initdb -E (EUC_JP,EUC_CN)      啟動資料庫 $ postmaster -i -D ~/data & 或者 pg_ctl start -l LOGFILE   5 . 使資料 庫 隨 開 機自運行
       cp 解 壓 包中的 contrib/start-scripts/linux 到 /etc/init.d Postgresql
       使用命令 chkconfig --add Postgresql 添加啟 動   6. 進入資料庫    $psql –U postgre –d postgres   7. 創 建 別 的用 戶 , 賦 於他 創 建資料 庫 的 權 限
      CREATE USER testuser CREATEDB; (如果是 createuser , 則為 超 級 用 戶權 限 )
8. 為 普通用 戶創 建資料 庫 ,也可由普通用 戶 登入模板資料 庫 自行 創 建
      CREATE DATABASE testdb OWNER testuser;   9. 到目前為止資料庫已經可以使用了,但是僅限本機串連要想網路中的機器也能訪問資料庫必須要配置/home/postgresql/data/下的兩個檔案pg_hba.conf和postgresql.conf   ① vi pg_hba.conf       添加:       host all all 192.168.100.0/24 trust ② vi postgresql.conf    添加:     listen_addresses = ‘*’     port = 5432     max_connections = 100   儲存後需要重啟資料庫         pg_ctl re start 10. 監控資料庫服務進程       ps auxww | grep postgres  

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.