一般我們在安裝postgres后,如果想用psql在控制臺(tái)登錄的話,是需要一點(diǎn)配置的。主要有以下幾步:
(1)安裝
?aptitude install postgresql-8.3
(2)修改系統(tǒng)用戶postgres的密碼
?這個(gè)postgres是你的系統(tǒng)用戶。
$ su (成功后)
# passwd postgres
(3)用postgres用戶登錄,修改數(shù)據(jù)庫用戶postgres的密碼
在postgres用戶環(huán)境下,你已經(jīng)可以用psql登錄
$ psql -h localhost -U postgres
postgres # alter user postgres password 'postgres';
(4)在其他用戶下,用psql登錄
XXX $ psql -hlocalhost -U postgres
就可以登錄了
通過上面的配置,就可以在本機(jī)用所有的用戶登錄了。
如果想通過其他的主機(jī)登錄postgres數(shù)據(jù)庫,還需要其他的配置。
(5)打開監(jiān)聽,配置如下
配置前
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)配置用戶授權(quán)
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
??
|----------------------------------------------------------------------------------------|
版權(quán)聲明 版權(quán)所有 @zhyiwww
引用請注明來源 http://www.aygfsteel.com/zhyiwww
|----------------------------------------------------------------------------------------|