zhyiwww
          用平實的筆,記錄編程路上的點點滴滴………
          posts - 536,comments - 394,trackbacks - 0
          一般我們在安裝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.aygfsteel.com/zhyiwww   
          |----------------------------------------------------------------------------------------|
          posted on 2009-06-26 15:41 zhyiwww 閱讀(531) 評論(0)  編輯  收藏 所屬分類: databaselinuxPostgres
          主站蜘蛛池模板: 丰都县| 同心县| 云阳县| 夏津县| 崇州市| 辽阳市| 贵溪市| 东辽县| 乐安县| 金山区| 广河县| 明溪县| 黑河市| 南通市| 洛扎县| 临江市| 屯昌县| 鸡东县| 社旗县| 白河县| 宝清县| 连江县| 红原县| 新源县| 荃湾区| 辛集市| 阜宁县| 常熟市| 北海市| 华蓥市| 轮台县| 云林县| 景宁| 镇巴县| 绥德县| 新泰市| 龙泉市| 博湖县| 贵德县| 万安县| 五家渠市|