安裝PostgreSQL資料庫(Linux篇)
0.編譯環境
- Linux: CentOS 5.5
- gcc: 4.1.2
1. 安裝PostgreSQL
1) 解壓postgresql-9.1.7.tar.bz2
#tar jxvf postgresql-9.1.7.tar.bz2
2) 進入解壓後的postgresql-9.1.7目錄
#cd postgresql-9.1.7
3) 編譯postgresql原始碼
#./configure --prefix=/opt/pgsql-9.1.7
#make
#make install
至此,完成postgresql的安裝。進入/opt/pgsql-9.1.7目錄可以看到安裝後的postgresql的檔案。
#ls /opt/pgsql-9.1.7
2.建立postgresql資料庫
1) 建立postgres使用者
#useradd postgres
修改postgres密碼
#passwd postgres
2) 設定postgres使用者的環境變數
切換到postgres使用者
#su - postgres
進入postgres的主目錄
#cd ~
編輯~/.bash_profile檔案
#vi ~/.bash_profile
設定以下的環境變數
export PGHOME=/opt/pgsql-9.1.7
export PGDATA=~/data
儲存,退出vi。執行以下命令,使環境變數生效
#source ~/.bash_profile
3) 初始化postgres資料庫
#initdb
至此,完成postgres資料庫的初始化。
4) 啟動postgres資料庫例項
#pg_ctl start
可以看到postgresql資料庫例項已經啟動,通過下面的命令可以檢視系統中執行的postgres程式
#ps -ef | grep postgres
5) 連線postgresql資料庫
#psql -h 127.0.0.1 -d postgres -U postgres
6) 停止postgresql資料庫例項
#pg_ctl stop
#ps -ef | grep postgres
可以看到已經沒有postgres程式
3. 設定PostgreSQL開機自啟動
PostgreSQL的開機自啟動指令碼位於PostgreSQL原始碼目錄的contrib/start-scripts路徑下
linux檔案即為linux系統上的啟動指令碼
1)修改linux檔案屬性,新增X屬性
#chmod a+x linux
2) 複製linux檔案到/etc/init.d目錄下,更名為postgresql
#cp linux /etc/init.d/postgresql
3)修改/etc/init.d/postgresql檔案的兩個變數
prefix設定為postgresql的安裝路徑:/opt/pgsql-9.1.2
PGDATA設定為postgresql的資料目錄路徑:
4) 執行service postgresql start,就可以啟動PostgreSQL服務
#service postgresql start
5)設定postgresql服務開機自啟動
#chkconfig --add postgresql
執行上面的命令,就可以實現postgresql服務的開機自啟動。
Please Note this is coming from http://www.cnblogs.com/marsprj/archive/2013/02/08/2893519.html
相關文章
- Alibaba Cloud Linux 安裝 PostgreSQL 資料庫CloudLinuxSQL資料庫
- 1. PostgreSQL 資料庫安裝SQL資料庫
- PostgreSQL 資料庫學習 - 0. 資料庫安裝SQL資料庫
- 講解Linux資料庫安裝Linux資料庫
- Linux下安裝Mysql資料庫LinuxMySql資料庫
- Linux安裝MariaDB資料庫-1Linux資料庫
- linux安裝postgresql三種方式LinuxSQL
- postgreSQL學習(一):在Linux下安裝postgreSQLSQLLinux
- Windows版PostgreSQL資料庫下載及安裝教程(關係型資料庫管理系統)WindowsSQL資料庫
- 【PG安裝】postgresql10 for linux 原始碼安裝SQLLinux原始碼
- Linux系統徹底解除安裝MySQL資料庫LinuxMySql資料庫
- protobuf安裝-Linux篇Linux
- Linux環境下達夢資料庫安裝及解除安裝手冊Linux資料庫
- MongoDB資料庫安裝MongoDB資料庫
- Redis 資料庫安裝Redis資料庫
- oricle資料庫安裝資料庫
- GreenPlum資料庫安裝資料庫
- Postgresql日常運維-安裝(Linux)01SQL運維Linux
- 資料視覺化第8篇:linux安裝davinci之davinci視覺化Linux
- 9、Linux下mysql資料庫安裝與配置實操LinuxMySql資料庫
- Oracle 資料庫打包安裝Oracle資料庫
- Ubuntu安裝MySQL資料庫UbuntuMySql資料庫
- tar方式安裝資料庫資料庫
- 達夢資料庫安裝資料庫
- 「Oracle」Oracle 資料庫安裝Oracle資料庫
- Hbase資料庫安裝部署資料庫
- 資料庫定時備份linux篇資料庫Linux
- Oracle Linux 7.1中安裝達夢資料庫DM7OracleLinux資料庫
- 想安裝PostgreSQL,看這篇也就夠了SQL
- 達夢8資料庫安裝和解除安裝資料庫
- oracle rac資料庫的安裝Oracle資料庫
- vgant 安裝oracle資料庫racOracle資料庫
- 安裝MySQL8資料庫MySql資料庫
- sqlserver資料庫下載安裝SQLServer資料庫
- 11. Oracle for Linux安裝和配置—11.3. Oracle安裝和配置—11.3.2. 資料庫建立OracleLinux資料庫
- postgresql 資料庫基本操作SQL資料庫
- postgresql資料庫利用方式SQL資料庫
- PostgreSQL-資料庫命令SQL資料庫
- postgresql 資料庫基本管理SQL資料庫