{"id":210972,"date":"2020-11-30T18:06:10","date_gmt":"2020-11-30T10:06:10","guid":{"rendered":"http:\/\/4563.org\/?p=210972"},"modified":"2020-11-30T18:06:10","modified_gmt":"2020-11-30T10:06:10","slug":"postgres-%e7%94%a8%e6%88%b7%e7%99%bb%e5%bd%95%e9%97%ae%e9%a2%98","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=210972","title":{"rendered":"postgres \u7528\u6237\u767b\u5f55\u95ee\u9898"},"content":{"rendered":"<div>\n<div>\n<div>\n<h1>                  postgres \u7528\u6237\u767b\u5f55\u95ee\u9898               <\/h1>\n<p> <\/p>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : zxCoder <\/span>  <span><i><\/i> 0<\/span> <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div isfirst=\"1\"> <\/p>\n<p>\u7cfb\u7edf\u662f ubuntu20.04 \uff0c\u6309\u7167\u5b98\u7f51\uff0c\u901a\u8fc7\u6dfb\u52a0\u8f6f\u4ef6\u6e90\uff0c\u7136\u540e\u5b89\u88c5 postgres\uff0c\u7136\u540e\u9ed8\u8ba4\u6709\u4e2a postgres \u7528\u6237\uff0c\u7136\u540e\u6211\u5148<code>sudo su - postgres<\/code>\u5207\u6362\u5230\u8fd9\u4e2a\u7528\u6237\uff0c\u7136\u540e<code>psql<\/code>\u76f4\u63a5\u8fdb\u5165\uff0c\u7136\u540e\u4fee\u6539\u5bc6\u7801\uff0c\u4e4b\u540e\u9000\u51fa\uff0c\u5207\u6362\u56de\u6211\u81ea\u5df1\u7684\u53e6\u4e00\u4e2a linux \u7528\u6237<code>test<\/code>\uff0c\u7136\u540e\u5728\u8fd9\u4e2a test \u7528\u6237\u8fd9\u91cc\uff0c\u4f7f\u7528<code>psql -U postgres<\/code>\u65e0\u6cd5\u8fdb\u5165\uff0c\u663e\u793a<code>psql: error: FATAL: Peer authentication failed for user \"postgres\"<\/code>\uff0c\u6bd4\u5982\u6307\u5b9a<code>psql -U postgres -h localhost<\/code>\u624d\u53ef\u4ee5\uff0c\u6216\u8005\u8bbe\u7f6e\u73af\u5883\u53d8\u91cf<code>PGHOST<\/code>\uff0c\u8fd9\u662f\u4e3a\u4ec0\u4e48\u5462\uff1f<\/p>\n<p>\u6ca1\u641c\u5230\u76f8\u5173\u7684\u4e1c\u897f\u554a\uff0c\u770b\u5f88\u591a\u6559\u7a0b\u4e5f\u6ca1\u6709\u63d0\u5230\u8fd9\u4e2a<\/p>\n<\/p><\/div>\n<div> <b>\u5927\u4f6c\u6709\u8a71\u8aaa<\/b> (<span>8<\/span>)        <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<ul>\n<li data-pid=\"4372093\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : CoderLife <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u6539 pg_hba.conf \u4e86\u6ca1\u6709                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4372094\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : zxCoder <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @CoderLife \u597d\u50cf\u6ca1\u6709\u8fd9\u4e2a\u6587\u4ef6                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4372095\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : airyland <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u201c\u6ca1\u641c\u5230\u76f8\u5173\u7684\u4e1c\u897f\u554a\u201d \u8fd9\u4e0d\u5927\u53ef\u80fd\uff0c\u76f4\u63a5\u7528 error \u90fd\u53ef\u4ee5\u5728 google \u53ef\u4ee5\u641c\u51fa\u7b54\u6848\uff0c\u6bd4\u5982\u8fd9\u4e2a\uff1a https:\/\/gist.github.com\/AtulKsol\/4470d377b448e56468baef85af7fd614 <button onclick=\"lazyGist(this)\">\u00a0\u663e\u793a Gist \u4ee3\u7801\u00a0<\/button> <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4372096\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : zxCoder <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @airyland \u65b0\u7248\u672c\u7684\u914d\u7f6e\u6587\u4ef6\u597d\u50cf\u4e0d\u592a\u4e00\u6837\u4e86\uff0c\u6211\u641c\u4e86\u5f88\u591a\u90fd\u662f\u8fd9\u6837\u5199\u7684\uff0c\u4fee\u6539\u914d\u7f6e\u6587\u4ef6\uff0c\u6539\u6210 trust\uff0c\u4f46\u662f\u6ca1\u7528\uff1b\u8fd9\u4e2a\u7f51\u5740\u6211\u4e5f\u770b\u5230\u8fc7 \u4e0b\u9762\u6709\u4e00\u4e2a\u4eba\u8bf4\u52a0\u4e0a-h localhost \u5c31\u53ef\u4ee5\u4e86\uff0c\u6211\u8bd5\u4e86\u4e00\u4e0b\u5c31\u662f\u8fd9\u6837\uff0c\u4f46\u662f\u4e0d\u77e5\u9053\u4e3a\u4ec0\u4e48                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4372097\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : mschultz <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @zxCoder \u4f60\u53ef\u4ee5 post \u51fa\u4f60\u7684 pg_hba.conf \u770b\u770b                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4372098\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : kidlj <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             reload \u4e86\u5417\uff1f                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4372099\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : zxCoder <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u89e3\u51b3\u4e86\u3002\u3002\u3002\u3002<\/p>\n<p>@CoderLife <br \/>@airyland <br \/>@mschultz <br \/>@kidlj <\/p>\n<p>&#8220;`<br \/># Database administrative login by Unix domain socket<br \/>local all postgres md5<\/p>\n<p># TYPE DATABASE USER ADDRESS METHOD<\/p>\n<p># &#8220;local&#8221; is for Unix domain socket connections only<br \/>local all all md5<br \/>&#8220;`<\/p>\n<p>\u6ca1\u6ce8\u610f\u5230\u4e0a\u9762\u7684\u90a3\u4e2a postgres\uff0c\u4e00\u76f4\u4fee\u6539\u7684\u662f\u4e0b\u9762\u90a3\u4e2a\u4e24\u4e2a all \u7684\u3002\u3002\u3002\u3002                                                            <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4372100\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : Sasasu <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             -h \u8d70 tcp socket. \u4e0d\u52a0\u8d70 unix domain socket.                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li>\n","protected":false},"excerpt":{"rendered":"<p>postgres \u7528\u6237\u767b\u5f55\u95ee\u9898 \u8cc7&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[],"tags":[],"_links":{"self":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/210972"}],"collection":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=210972"}],"version-history":[{"count":0,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/210972\/revisions"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=210972"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=210972"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=210972"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}