Linux下PostgreSQL如何源碼安裝-創(chuàng)新互聯(lián)

這篇文章將為大家詳細(xì)講解有關(guān)Linux下PostgreSQL如何源碼安裝,小編覺得挺實用的,因此分享給大家做個參考,希望大家閱讀完這篇文章后可以有所收獲。

創(chuàng)新互聯(lián)自2013年起,是專業(yè)互聯(lián)網(wǎng)技術(shù)服務(wù)公司,擁有項目網(wǎng)站制作、網(wǎng)站建設(shè)網(wǎng)站策劃,項目實施與項目整合能力。我們以讓每一個夢想脫穎而出為使命,1280元壽寧做網(wǎng)站,已為上家服務(wù),為壽寧各地企業(yè)和個人服務(wù),聯(lián)系電話:18982081108

1、首先安裝依賴包,避免在安裝過程中出現(xiàn)問題

shell> yum install gcc gcc-c++ automake autoconf libtool make
shell> yum install readline-devel
shell> yum install zlib-devel

2、創(chuàng)建postgre用戶及用戶組

shell> groupadd postgre
shell> useradd -g postgre postgre   
shell> passwd postgre                #修改密碼
shell> id postgre
uid=500(postgre) gid=501(postgre) 組=501(postgre)

3、編譯安裝postgre

shell> tar zxvf postgresql-9.3.6.tar.gz
shell> cd postgresql-9.3.6
shell> ./configure --prefix=/db/pgsql
shell> make && make install  
PostgreSQL installation complete.

4、設(shè)置數(shù)據(jù)庫目錄權(quán)限并初始化數(shù)據(jù)庫

shell> mkdir -p /db/pgsql/data
shell> chown -R postgre.postgre /db/pgsql/
shell> cp contrib/start-scripts/linux /etc/rc.d/init.d/postgresql
shell> su - postgre

# 初始化數(shù)據(jù)庫
shell> /db/pgsql/bin/initdb -D /db/pgsql/data/
The files belonging to this database system will be owned by user "postgre".
This user must also own the server process.

The database cluster will be initialized with locale "zh_CN.UTF-8".
The default database encoding has accordingly been set to "UTF8".
initdb: could not find suitable text search configuration for locale "zh_CN.UTF-8"
The default text search configuration will be set to "simple".

Data page checksums are disabled.

fixing permissions on existing directory /db/pgsql/data ... ok
creating subdirectories ... ok
selecting default max_connections ... 100
selecting default shared_buffers ... 128MB
creating configuration files ... ok
creating template1 database in /db/pgsql/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
syncing data to disk ... ok

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

Success. You can now start the database server using:

    /db/pgsql/bin/postgres -D /db/pgsql/data/
or
    /db/pgsql/bin/pg_ctl -D /db/pgsql/data/ -l logfile start

5、設(shè)置環(huán)境變量

shell> vi .bash_profile
==================================================================
PATH=$PATH:$HOME/bin:/db/pgsql/bin
export PGDATA=/db/pgsql/data
export PGHOME=/db/pgsql
export LANG=zh_CN.UTF-8
export PGPORT=5432
export PATH
==================================================================
shell> source .bash_profile

6、開啟postgre服務(wù)

shell> pg_ctl -D /db/pgsql/data/ -l /db/pgsql/log/logfile start 
server starting

shell> tail -f /db/pgsql/logfile
LOG:  database system was shut down at 2015-04-20 17:59:36 CST
LOG:  database system is ready to accept connections
LOG:  autovacuum launcher started

7、測試連接數(shù)據(jù)庫

shell> createdb mydb
shell> psql -h 127.0.0.1 -p 5432 -U postgre -W mydb
Password for user postgre: 
psql (9.3.6)
Type "help" for help.

mydb=# 

# 顯示當(dāng)前數(shù)據(jù)庫
mydb=# \l
                                List of databases
   Name    |  Owner  | Encoding |   Collate   |    Ctype    |  Access privileges  
-----------+---------+----------+-------------+-------------+---------------------
 mydb      | postgre | UTF8     | zh_CN.UTF-8 | zh_CN.UTF-8 | 
 postgres  | postgre | UTF8     | zh_CN.UTF-8 | zh_CN.UTF-8 | 
 template0 | postgre | UTF8     | zh_CN.UTF-8 | zh_CN.UTF-8 | =c/postgre         +
           |         |          |             |             | postgre=CTc/postgre
 template1 | postgre | UTF8     | zh_CN.UTF-8 | zh_CN.UTF-8 | =c/postgre         +
           |         |          |             |             | postgre=CTc/postgre
(4 rows)

# 退出命令行
mydb=# \q

關(guān)于“Linux下PostgreSQL如何源碼安裝”這篇文章就分享到這里了,希望以上內(nèi)容可以對大家有一定的幫助,使各位可以學(xué)到更多知識,如果覺得文章不錯,請把它分享出去讓更多的人看到。

標(biāo)題名稱:Linux下PostgreSQL如何源碼安裝-創(chuàng)新互聯(lián)
網(wǎng)頁網(wǎng)址:http://muchs.cn/article12/cdsogc.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供手機網(wǎng)站建設(shè)、網(wǎng)站導(dǎo)航、網(wǎng)站制作、定制網(wǎng)站網(wǎng)站設(shè)計公司、用戶體驗

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

成都網(wǎng)頁設(shè)計公司