PostgreSQL 建立一個新的database system

來源:互聯網
上載者:User

第一步:su postgres

第二步:bash-4.2$ /usr/pgsql-9.1/bin/initdb -D /var/lib/pgsql/9.1/data/  , 斷行符號後出現如下資訊

The files belonging to this database system will be owned by user "postgres".
This user must also own the server process.


The database cluster will be initialized with locale en_US.UTF-8.
The default database encoding has accordingly been set to UTF8.
The default text search configuration will be set to "english".


fixing permissions on existing directory /var/lib/pgsql/9.1/data ... ok
creating subdirectories ... ok
selecting default max_connections ... 100
selecting default shared_buffers ... 24MB
creating configuration files ... ok
creating template1 database in /var/lib/pgsql/9.1/data/base/1 ... ok
initializing pg_authid ... ok
initializing dependencies ... ok
creating system views ... ok
loading system objects' descriptions ... ok
creating collations ... ok
creating conversions ... ok
creating dictionaries ... ok
setting privileges on built-in objects ... ok
creating information schema ... ok
loading PL/pgSQL server-side language ... ok
vacuuming database template1 ... ok
copying template1 to template0 ... ok
copying template1 to postgres ... ok


WARNING: enabling "trust" authentication for local connections
You can change this by editing pg_hba.conf or using the -A option the
next time you run initdb.


Success. You can now start the database server using:


    /usr/pgsql-9.1/bin/postgres -D /var/lib/pgsql/9.1/data
or

    /usr/pgsql-9.1/bin/pg_ctl -D /var/lib/pgsql/9.1/data -l logfile start


第三步:用上邊兩個命令中的一個啟動服務

第四步:建立一個使用者(user)

bash-4.2$ createuser qiaoning -P

Enter password for new role: //輸入密碼
Enter it again: //再次輸入密碼
Shall the new role be a superuser? (y/n) n //是否是超級使用者,選否

Shall the new role be allowed to create databases? (y/n) y //該使用者是否可以建立資料庫,選是
Shall the new role be allowed to create more new roles? (y/n) n //該使用者是否可以建立新的角色,選否

第五步:建立資料庫

bash-4.2$ createdb qiaoning --owner=qiaoning   //第一個qiaoning是資料庫名稱,第二個qiaoning是資料庫的擁有者


以上步驟完成後需要修改一些設定檔(主要是存取權限的設定)

第一步:進入剛才建立的database system所在的目錄,即:/var/lib/pgsql/9.1/data/

  • 1
  • 2
  • 下一頁

聯繫我們

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