標籤:
postgreSQL在linux中安裝詳解 收藏
這裡安裝8.4.4版本,首先下載postgresql-8.4.4-1-linux.bin。
(http://www.postgresql.org/download/)下載linux32版本的
1. 如果該檔案不在linux系統中,將其從Windows拖到linux系統中,放到任意一個目錄下,最好放在/opt或者/home。推薦一個Windows檔案轉到linux的工具:WinSCP3
(
1、開啟一個終端,su -成root使用者;
2、chmod +xpostgresql-8.4.4-1-linux.bin
3、./postgresql-8.4.4-1-linux.bin //運行這個命令就可以安裝軟體了)
2. [[email protected] ~]# /postgresql-8.4.1-1-linux-x64.bin – –mode text (我這裡是放在了root路徑下)
—————————————————————————
Welcome to the PostgreSQL Setup Wizard.
—————————————————————————
Please specify the directory where PostgreSQL will be installed.
3. Installation Directory [/opt/PostgreSQL/8.4]: (這裡直接斷行符號,表示裝在/opt目錄下)
—————————————————————————
Please select a directory under which to store your data.
4. Data Directory [/opt/PostgreSQL/8.4/data]:(這裡直接斷行符號,表示data資料裝在該目錄下)
—————————————————————————
Please provide a password for the database superuser (postgres). A locked Unix user account (postgres) will be created if not present.
5. Password :[ 輸入密碼]
6. Retype password :[ 重複輸入]
—————————————————————————
7. Please select the port number the server should listen on.
Port [5432]:[ 預設連接埠,直接斷行符號]
[616] yi_US
[617] yi_US.utf8
[618] zh_CN
[619] zh_CN.utf8
[620] zh_HK
[621] zh_HK.utf8
[622] zh_SG
[623] zh_SG.utf8
[624] zh_TW
[625] zh_TW.euctw
[626] zh_TW.utf8
[627] zu_ZA
[628] zu_ZA.iso88591
[629] zu_ZA.utf8
Please choose an option [1] :619[ 預設字元集]
8. Install pl/pgsql in template1 database? [Y/n]: n[是否安裝模板庫,這裡選否]
—————————————————————————-
Setup is now ready to begin installing PostgreSQL on your computer.
9. Do you want to continue? [Y/n]: y[ 是否繼續安裝]
—————————————————————————-
Please wait while Setup installs PostgreSQL on your computer.
Installing
0% ______________ 50% ______________ 100%
########################################
—————————————————————————-
Setup has finished installing PostgreSQL on your computer.
Launch Stack Builder at exit?
10. Stack Builder may be used to download and install additional tools, drivers and applications to complement your PostgreSQL installation. [Y/n]: y(這裡是繼續安裝額外的工具,驅動和先關應用程式)
到這裡資料庫就安裝成功了,然後就需要配置使用者,環境變數,以及初始化資料庫
11. [[email protected] ~]# cp .bash_profile .bashrc /home/PostgreSQL/8.4/ (將檔案拷到相應目錄,這個是配置環境變數的)
[[email protected] ~]# chown -R postgres.postgres /home/PostgreSQL/* (將改檔案的owner和group都配置為postgres)
12. [[email protected] ~]# ls -ltr /home/PostgreSQL/8.4/.bash* (查看下是否已更改)
-rw-r–r– 1 postgres postgres 174 Nov 10 19:18 /home/PostgreSQL/8.4/.bash_profile
-rw-r–r– 1 postgres postgres 176 Nov 10 19:18 /home/PostgreSQL/8.4/.bashrc
初始化該資料庫叢集的預設地區和字元集編碼
13. [[email protected] ~]#su – postgres(轉到postgres使用者下)
14. [[email protected] ~]$/opt/PostgreSQL/8.4/bin/initdb –D /opt/PostgreSQL/8.4/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.
The default database encoding has accordingly been set to LATIN1.
The default text search configuration will be set to "english".
fixing permissions on existing directory /home/PostgreSQL/8.4/data … ok
creating subdirectories … ok
selecting default max_connections … 100
selecting default shared_buffers … 32MB
creating configuration files … ok
creating template1 database in /home/PostgreSQL/8.4/data/base/1 … o
initializing pg_authid … ok
initializing dependencies … ok
creating system views … ok
loading system objects’ descriptions … ok
creating conversions … ok
creating dictionaries … ok
setting privileges on built-in objects … ok
creating information schema … 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:
postgres -D /home/PostgreSQL/8.4/data
or
pg_ctl -D /home/PostgreSQL/8.4/data -l logfile start
恭喜你,現在就把所有的都裝完了!
常用命令:
Createdb
建立資料庫
Createuser
建立資料庫使用者
Dropdb
刪除資料庫
Dropuser
刪除資料庫使用者
Psql
互動式PostgreSQL前端工具,可以用它來操作資料庫
Initdb
初始化postgreSQL資料庫
例如:
psql \q à 退出psql命令符介面
psql \c dbname à 串連資料庫
pg_ctl -D /opt/PostgreSQL/8.4/data/ status à 查看當前服務狀態
pg_ctl -D /opt/PostgreSQL/8.4/data/ start à 啟動服務
pg_ctl -D /opt/PostgreSQL/8.4/data/ stop à 停止服務
遠程登入設定:
●開啟opt/PostgreSQL/8.4/data/pg_hba.conf,像下面一樣添加一行代碼:(紅色為添加的)
# IPv4 local connections:
host all all 0.0.0.0/0 md5
host all all 127.0.0.1/32 md5
這行代碼錶示所有IP地址的所有使用者可以通過md5加密的方式遠程登入。
●開啟opt/PostgreSQL/8.4/data/postgresql.conf
按照下面的寫:
listen_addresses = ‘*‘
port = 5432
max_connections = 100
這裡表示監聽來自所有IP的響應。
本文來自CSDN部落格,轉載請標明出處:http://blog.csdn.net/william_zheng2010/archive/2010/07/12/5728333.aspx
postgreSQL在linux中安裝詳解