centos用yum安裝postgresql的路徑為 /var/lib/pgsql/中。
1.安裝postgresql9.0 yum 倉(cāng)庫(kù)
rpm -i http://www.tjdsmy.cn/9.2/redhat/rhel-6-x86_64/pgdg-redhat92-9.2-7.noarch.rpm
2.安裝新版本的Postgresql
yum install postgresql92-server postgresql92-contrib
3.初始化數(shù)據(jù)庫(kù)
/etc/init.d/postgresql-9.2 initdb
4.啟動(dòng)數(shù)據(jù)庫(kù)
/etc/init.d/postgresql-9.2 start
注意:postgresql啟動(dòng)后就可以利用service postgresql-9.2 start/restart/stop來(lái)控制它了。
雖然打完service后,按p不提示postgresql-9.2,但是可以用手輸。
5.把postgresql加入自啟動(dòng)列表
cd /etc/init.d
chkconfig --add postgresql9.2
6.查看一下自啟動(dòng)列表
chkconfig --list
在這里可以看到postgresql已經(jīng)在其中了。
7.PostgreSQL 數(shù)據(jù)庫(kù)默認(rèn)會(huì)創(chuàng)建一個(gè)postgres的數(shù)據(jù)庫(kù)用戶作為數(shù)據(jù)庫(kù)的管理員,默認(rèn)密碼為空,我們需要修改為指定的密碼,這里設(shè)定為’postgres’
直接在控制臺(tái)輸入以下命令:
# su - postgres
$ psql
# ALTER USER postgres WITH PASSWORD 'postgres';
# select * from pg_shadow ;
# create database david;
# c david
david=# create table test (id integer, name text);
david=# insert into test values (1,'david');
至上,安裝成功。
-----------------------------------------------------------
ps:1.可以通過(guò)查找pg_hba.conf,來(lái)定位postgresql的位置。
2.重啟postgresql,可以用service postgresql restart