ȱʡµÄʱºò£¬¿Í»§¶ËÖ»ÄÜͨ¹ýÒ»¸ö±¾µØµÄ Unix Ì×½Ó×ÖÁª½Óµ½Êý¾Ý¿â·þÎñÆ÷ÉÏÀ´£¬¶ø²»ÊÇͨ¹ý TCP/IP Ì×½Ó×Ö¡£ºó¶Ë±ØÐë´ø -i Ñ¡ÏîÆô¶¯²ÅÄÜÔÊÐí·Ç±¾µØµÄ¿Í»§¶ËÁª½ÓÉÏÀ´¡£
¿ÉÒÔͨ¹ýÔÚ PG_DATA ÀïµÄ pg_hba.conf ÎļþÀ´ÏÞÖÆ¿ÉÁª½ÓµÄ¿Í»§¶Ë IP µØÖ·ºÍ/»òÓû§Ãû¡£
¿Í»§¶ËÁª½Ó¿ÉÒÔͨ¹ýÆäËûÍⲿÈí¼þ°üÀ´ÈÏÖ¤¡£
Postgres ÀïµÄÿ¸öÓû§¶¼¸³ÓèÁËÒ»¸öÓû§ÃûºÍÒ»¸ö£¨¿ÉÑ¡µÄ£©¿ÚÁȱʡÊÇ£¬Óû§¶Ô²»ÊÇËûÃÇ´´½¨µÄÊý¾Ý¿âûÓÐдȨÏÞ¡£
Óû§¿ÉÒÔ¸³Óè×飬¶øÇÒ±íµÄ·ÃÎÊȨÏÞ¿ÉÒÔÒÔ×éȨÏÞΪ»ù´¡ÉèÖá£
ÿ¸öÊý¾Ý¿âϵͳ¶¼°üº¬Ò»¸öÎļþ½Ð pg_hba.conf£¬ÔÚÆä PGDATA Ŀ¼À¸ÃÎļþ¿ØÖÆË¿ÉÒÔÁª½Óµ½¸÷×ÔµÄÊý¾Ý¿â¡£
ÿ¸öÕýÔÚ·ÃÎÊÊý¾Ý¿âµÄ¿Í»§¶Ë±ØÐë±» pg_hba.conf ÀïµÄÆäÖÐÒ»Ìõ¼Ç¼º¸Ç¡£·ñÔòËùÓдÓÄǸö¿Í»§¶Ë·¢ËÍÉÏÀ´µÄÁª½ÓÇëÇ󶼽«±»¾Ü¾ø£¬´íÎóÐÅϢΪ "User authentication failed" £¨Óû§ÈÏ֤ʧ°Ü£©¡£
Îļþ pg_hba.conf µÄ³£ÓøñʽÊÇÒ»Ì׼Ǽ£¬Ã¿ÐÐÒ»Ìõ¡£¿Õ°×ÐлòÕßÔÓÂÒ·ûºÅ£¨"#"£©¿ªÍ·µÄÐб»ºöÂÔ¡£Ò»Ìõ¼Ç¼ÊÇÓÉÈô¸ÉÓÿոñºÍ/»ò tab ·Ö¸ôµÄ×Ö¶Î×é³É¡£
´Ó¿Í»§¶ËÀ´µÄÁª½Ó¿ÉÒÔʹÓà Unix ÓòÌ×½Ó×Ö»òÕßÍø¼ÊÍøÓòÌ×½Ó×Ö£¨ÀýÈ磺TCP/IP£©½¨Á¢¡£Óà Unix ÓòÌ×½Ó×Ö½øÐеÄÁª½ÓÊÇÓÃÏÂÃæ¸ñʽµÄ¼Ç¼½øÐпØÖƵģº
local database authentication method͉˕
database ÉùÃ÷¼Ç¼ËùÓ¦ÓõÄÊý¾Ý¿â¡£Öµ all ±íÃ÷¸Ã¼Ç¼ӦÓÃÓÚËùÓÐÊý¾Ý¿â¡£ |
authentication method ÉùÃ÷Ò»¸öÓû§ÔÚÓà Unix ÓòÌ×½Ó×ÖÓë¸ÃÊý¾Ý¿âÁª½ÓʱÓÃÓÚÈÏÖ¤ËûÃÇ×ÔÉíµÄ·½·¨¡£²»Í¬µÄ·½·¨ÔÚÏÂÃæÃèÊö¡£ |
ÓÃÍø¼ÊÍø£¨IP£©ÓòÌ×½Ó×Ö½øÐеÄÁª½ÓÊÇÓÃÏÂÃæ¸ñʽµÄ¼Ç¼½øÐпØÖƵģº
host database TCP/IP address TCP/IP mask authentication methodTCP/IP address Âß¼ÉÏÓëÉùÃ÷µÄ TCP/IP mask ºÍÕýÔÚÁª½ÓµÄ¿Í»§¶ËµÄ TCP/IP µØÖ··Ö±ðÏà¼Ó¡£Èç¹ûÁ½¸ö½á¹ûÏàµÈÔò¸Ã¼Ç¼ÓÃÓÚÕâ´ÎÁª½Ó¡£Èç¹ûÒ»¸öÁª½ÓÆ¥Åä¶àÓÚÒ»Ìõ¼Ç¼£¬ÄÇôʹÓÃÎļþÀïµÚÒ»ÌõÆ¥ÅäµÄ¼Ç¼¡£ TCP/IP address ºÍ TCP/IP mask ¶¼ÊÇÓõã·ÖÊ®½øÖÆ·ûºÅ±íʾµÄ¡£
Èç¹ûÒ»¸öÁª½Ó²»ÄܺÍÈκμǼÏàÆ¥Å䣬ÔòÓ¦ÓþܾøÈÏÖ¤·½·¨£¨¼ûÏÂÎÄ£©¡£
# Trust any connection via Unix domain sockets. local trust # Trust any connection via TCP/IP from this machine. host all 127.0.0.1 255.255.255.255 trust # We don't like this machine. host all 192.168.0.10 255.255.255.0 reject # This machine can't encrypt so we ask for passwords in clear. host all 192.168.0.3 255.255.255.0 password # The rest of this group of machines should provide encrypted passwords. host all 192.168.0.0 255.255.255.0 crypt