一般我們在安裝postgres后,如果想用psql在控制臺登錄的話,是需要一點配置的。主要有以下幾步:
(1)安裝
?aptitude install postgresql-8.3
(2)修改系統用戶postgres的密碼
?這個postgres是你的系統用戶。
$ su (成功后)
# passwd postgres
(3)用postgres用戶登錄,修改數據庫用戶postgres的密碼
在postgres用戶環境下,你已經可以用psql登錄
$ psql -h localhost -U postgres
postgres # alter user postgres password 'postgres';
(4)在其他用戶下,用psql登錄
XXX $ psql -hlocalhost -U postgres
就可以登錄了
通過上面的配置,就可以在本機用所有的用戶登錄了。
如果想通過其他的主機登錄postgres數據庫,還需要其他的配置。
(5)打開監聽,配置如下
配置前
root@zhangyi-desktop:/home/zhangyi# grep -i listen? /etc/postgresql/8.3/main/postgresql.conf
# what IP address(es) to listen on;
listen_addresses = 'localhost'?? ???? # what IP address(es) to listen on;
root@zhangyi-desktop:/home/zhangyi#
配置后
root@zhangyi-desktop:/home/zhangyi# grep -i listen? /etc/postgresql/8.3/main/postgresql.conf
listen_addresses = '*'?? ????
# what IP address(es) to listen on;
#listen_addresses = 'localhost'?? ????
# what IP address(es) to listen on;
root@zhangyi-desktop:/home/zhangyi#
(6)配置用戶授權
vim /etc/postgresql/8.3/main/pg_hba.conf
添加
host??? all???????? all???????? 192.168.1.0/24????????? md5
(7)重啟postgres
# /etc/init.d/postgres restart
??
|----------------------------------------------------------------------------------------|
版權聲明 版權所有 @zhyiwww
引用請注明來源 http://www.tkk7.com/zhyiwww
|----------------------------------------------------------------------------------------|
posted on 2009-06-26 15:41
zhyiwww 閱讀(529)
評論(0) 編輯 收藏 所屬分類:
database 、
linux 、
Postgres