{"id":2906,"date":"2018-07-12T16:17:59","date_gmt":"2018-07-12T08:17:59","guid":{"rendered":"http:\/\/liyue.name\/blog\/?p=2906"},"modified":"2026-02-10T22:14:31","modified_gmt":"2026-02-10T14:14:31","slug":"centos-7%e5%ae%89%e8%a3%85postgresql%e7%9a%84%e6%96%b9%e6%b3%95","status":"publish","type":"post","link":"https:\/\/liyue.name\/?p=2906","title":{"rendered":"CentOS 7\u5b89\u88c5PostgreSQL\u7684\u65b9\u6cd5"},"content":{"rendered":"<p><strong>\u64cd\u4f5c\u7cfb\u7edf\uff1a<\/strong><br \/>\ncentos-release-7-5.1804.el7.centos.x86_64<em>\uff08<a href=\"https:\/\/www.centos.org\/download\/\" target=\"_blank\" rel=\"noopener noreferrer\">\u5b98\u7f51<\/a> | <a href=\"http:\/\/mirrors.163.com\/centos\/7\/isos\/x86_64\/CentOS-7-x86_64-Minimal-1804.iso\" target=\"_blank\" rel=\"noopener noreferrer\">163\u4e0b\u8f7dmini\u7248<\/a> \uff09<\/em><br \/>\n<strong>PostgreSQL\u7248\u672c\uff1a<\/strong><br \/>\npostgresql.x86_64 9.2.23-3.el7_4<br \/>\npostgresql-libs.x86_64 9.2.23-3.el7_4<br \/>\npostgresql-server.x86_64 9.2.23-3.el7_4<br \/>\n<!--more--><br \/>\n<strong>\u5b89\u88c5\u5e76\u542f\u52a8\u6570\u636e\u5e93<\/strong><em>\uff08\u5982\u679c\u5728\u9605\u8bfb\u300a\u4e03\u5468\u4e03\u6570\u636e\u5e93\u300b\u4e66\uff0c\u5b89\u88c5\u65f6\u589e\u52a0\u6269\u5c55\u5305\u6216<a href=\"https:\/\/liyue.name\/?p=2915\">\u70b9\u8fd9\u91cc<\/a>\uff09<\/em><br \/>\n[root@localhost ~]# <code>yum install -y postgresql-server<\/code><br \/>\n[root@localhost ~]# <code>postgresql-setup initdb<\/code><br \/>\n[root@localhost ~]# <code>systemctl enable postgresql<\/code><br \/>\nCreated symlink from \/etc\/systemd\/system\/multi-user.target.wants\/postgresql.service to \/usr\/lib\/systemd\/system\/postgresql.servic<br \/>\ne.<br \/>\n[root@localhost ~]# <code>systemctl start postgresql<\/code><br \/>\n<strong>\u7f16\u8f91postgresql.conf\u6587\u4ef6\u8bbe\u7f6e\u76d1\u542cIP\uff1a<\/strong><br \/>\n[root@localhost ~]# <code>vi \/var\/lib\/pgsql\/data\/postgresql.conf<\/code><br \/>\n# &#8211; Connection Settings &#8211;<br \/>\n<code>listen_addresses = '*' <\/code><br \/>\n<strong>\u7f16\u8f91pg_hba.conf\u6587\u4ef6\u8bbe\u7f6e\u5141\u8bb8\u8fde\u63a5\u7684IP\uff08\u6240\u6709IP\u90fd\u80fd\u8fde\u63a5\uff09\uff1a<\/strong><br \/>\n[root@localhost ~]# <code>vi \/var\/lib\/pgsql\/data\/pg_hba.conf<\/code><br \/>\n# IPv4 local connections:<br \/>\nhost all all 127.0.0.1\/32 ident<br \/>\n<code>host all all 0.0.0.0\/0 md5<\/code><br \/>\n<strong>\u8bbe\u7f6e\u7528\u6237postgres\u7684\u5bc6\u7801<\/strong><br \/>\n[root@localhost ~]# <code>su - postgres<\/code><br \/>\n-bash-4.2$ <code>psql<\/code><br \/>\npsql (9.2.23)<br \/>\nType &#8220;help&#8221; for help.<br \/>\npostgres=#<code> alter user postgres with password 'your password';<\/code><br \/>\nALTER ROLE<br \/>\npostgres=# <code>\\q<\/code><br \/>\n-bash-4.2$<code> \\exit<\/code><br \/>\nlogout<br \/>\n<strong>\u91cd\u542f\u6570\u636e\u5e93\uff1a<\/strong><br \/>\n[root@localhost ~]# <code>systemctl restart postgresql<\/code><br \/>\n<strong>\u8bbe\u7f6e\u9632\u706b\u5899\uff1a<\/strong><br \/>\n[root@localhost services]# <code>firewall-cmd --add-service=postgresql --permanent<\/code><br \/>\nsuccess<br \/>\n[root@localhost services]# <code>firewall-cmd --reload<\/code><br \/>\nsuccess<br \/>\n<em>\u5982\u679c\u4e0d\u60f3\u5728Linux\u7cfb\u7edf\u4e0b\u64cd\u4f5c\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u514d\u8d39\u8f6f\u4ef6\uff08\u652f\u6301Windows\/macOS\/Linux\u5e73\u53f0\uff09<br \/>\npgAdmin\uff08web\u7aef\uff09 \u4e0b\u8f7d\u5730\u5740\uff1a<a href=\"https:\/\/www.pgadmin.org\/download\" target=\"_blank\" rel=\"noopener noreferrer\">https:\/\/www.pgadmin.org\/download<\/a> <\/em><br \/>\n<em>DBeaver\u5ba2\u6237\u7aef \u4e0b\u8f7d\u5730\u5740\uff1a<a href=\"https:\/\/dbeaver.io\/download\/\" target=\"_blank\" rel=\"noopener noreferrer\">https:\/\/dbeaver.io\/download\/<\/a><\/em><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u64cd\u4f5c\u7cfb\u7edf\uff1a centos-release-7-5.1804.el7.centos.x86_64\uff08\u5b98\u7f51 | 16 &hellip; <a href=\"https:\/\/liyue.name\/?p=2906\" class=\"more-link\">\u7ee7\u7eed\u9605\u8bfb<span class=\"screen-reader-text\">\u201cCentOS 7\u5b89\u88c5PostgreSQL\u7684\u65b9\u6cd5\u201d<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5,24],"tags":[76,177,444],"class_list":["post-2906","post","type-post","status-publish","format-standard","hentry","category-linux","category-24","tag-centos","tag-postgresql","tag-444"],"_links":{"self":[{"href":"https:\/\/liyue.name\/index.php?rest_route=\/wp\/v2\/posts\/2906","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/liyue.name\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/liyue.name\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/liyue.name\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/liyue.name\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2906"}],"version-history":[{"count":2,"href":"https:\/\/liyue.name\/index.php?rest_route=\/wp\/v2\/posts\/2906\/revisions"}],"predecessor-version":[{"id":5766,"href":"https:\/\/liyue.name\/index.php?rest_route=\/wp\/v2\/posts\/2906\/revisions\/5766"}],"wp:attachment":[{"href":"https:\/\/liyue.name\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2906"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/liyue.name\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2906"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/liyue.name\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2906"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}