postgresql centos6.5安裝以及常用命令

來源:互聯網
上載者:User

標籤:

   今天在centos6.5下安裝postgresql資料庫,現在整理自己操作步驟。

一. Centos6.5 下安裝postgresql9.4

 1.1. 顯示所有的有關postgresql安裝包

    yum list postgres*

1.2. 安裝資料庫

    yum install postgresql94-server
1.2. 初始化資料庫(初始化資料庫預設路徑在/var/lib/pgsql/9.4/data)
service install postgresql-9.4 initdb
1.3. 啟動服務
service postgresql9.4 start

二. postgresql資料庫密碼設定

  2.1. 切換使用者到postgres

      su - postgres

  2.2. 串連資料庫

    psql -U postgres

  3.3. 為使用者名稱設定密碼

    \password postgres(設定密碼)

    alter user postgres with password ‘123456‘(修改)

  3.4. 修改預設的驗證方式(重要)

    

    在/var/lib/pgsql/data/pg_hba.conf中,將預設驗證方法

        host all all 127.0.0.1/32 ident

         改為密碼驗證

         host all all 127.0.0.1/32 md5

  3.5. 重啟資料庫

                systemctl restart postgresql

  3.6. 新使用者登陸

    psql -U postgres -h 127.0.0.1 

四. 資料庫匯入匯出命令

       4.1. 備份

      備份資料庫:
      -bash-3.2$ pg_dump music >/tmp/music.dmp

      查看備份:

        -bash-3.2$ cd /tmp/
        -bash-3.2$ ls

   4.2. 匯入 

psql -U postgres(使用者名稱)  資料庫名(預設時同使用者名稱) < /data/dum.sql

 

 

 

postgresql centos6.5安裝以及常用命令

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.