{"id":1291,"date":"2022-09-06T09:57:00","date_gmt":"2022-09-06T01:57:00","guid":{"rendered":"http:\/\/175.24.184.226\/?p=1291"},"modified":"2022-09-06T09:57:00","modified_gmt":"2022-09-06T01:57:00","slug":"%e4%bb%a5windows%e6%9c%8d%e5%8a%a1%e6%96%b9%e5%bc%8f%e5%bf%ab%e9%80%9f%e9%83%a8%e7%bd%b2%e5%85%8d%e5%ae%89%e8%a3%85%e7%89%88postgres%e6%95%b0%e6%8d%ae%e5%ba%93","status":"publish","type":"post","link":"\/?p=1291","title":{"rendered":"\u4ee5windows\u670d\u52a1\u65b9\u5f0f\u5feb\u901f\u90e8\u7f72\u514d\u5b89\u88c5\u7248Postgres\u6570\u636e\u5e93"},"content":{"rendered":"<h1>\u4ee5windows\u670d\u52a1\u65b9\u5f0f\u5feb\u901f\u90e8\u7f72\u514d\u5b89\u88c5\u7248Postgres\u6570\u636e\u5e93<\/h1>\n<h2>1\u3001\u4e0b\u8f7dPostgresql\u6570\u636e\u5e93\u514d\u5b89\u88c5\u5305<\/h2>\n<p><strong>\u4e0b\u8f7d\u5730\u5740<\/strong><\/p>\n<p><code>https:\/\/www.enterprisedb.com\/download-postgresql-binaries<\/code><\/p>\n<p>\u5982\u4e0b\u56fe\uff1a<\/p>\n<p><img src=\"https:\/\/lemon-guess.oss-cn-hangzhou.aliyuncs.com\/img\/202209060955535.png\" alt=\"\" \/><\/p>\n<p>\u8fd9\u6b21\u6211\u76f4\u63a5\u4e0b\u8f7d\u6700\u65b0\u768412.1\u7684\u514d\u5b89\u88c5\u7684\u5305\u3002<\/p>\n<p>\u6587\u4ef6\u7684\u4e0b\u8f7d\u94fe\u63a5\uff1a<\/p>\n<p><code>http:\/\/get.enterprisedb.com\/postgresql\/postgresql-12.1-3-windows-x64-binaries.zip<\/code><\/p>\n<p>\u4e0b\u8f7d\u7684\u6587\u4ef6\u540d\uff1a<\/p>\n<p><code>postgresql-12.1-3-windows-x64-binaries.zip<\/code><\/p>\n<h2>2\u3001\u5b89\u88c5\u73af\u5883\u51c6\u5907\u53ca\u9a8c\u8bc1<\/h2>\n<h3>\u89e3\u538b\u6587\u4ef6<\/h3>\n<p>\u89e3\u538b\u4e0b\u8f7d\u597d\u7684\u5b89\u88c5\u5305\u81f3\u5b89\u88c5\u76ee\u5f55\uff0c\u6211\u76f4\u63a5\u5b89\u88c5\u5230\u672c\u673a\u7684<code>C:\\Program Files\\PostgreSQL\\pgsql<\/code> \u76ee\u5f55\u3002<\/p>\n<p>\u6700\u7ec8\u7684\u76ee\u5f55\u7ed3\u6784\u5982\u4e0b\u56fe\uff1a<\/p>\n<p><img src=\"https:\/\/lemon-guess.oss-cn-hangzhou.aliyuncs.com\/img\/202209060955686.png\" alt=\"\" \/><\/p>\n<hr \/>\n<h3>\u6d4b\u8bd5\u73af\u5883\u4f9d\u8d56<\/h3>\n<p>\u901a\u8fc7cmd\u547d\u4ee4\u7a97\u53e3\u8fdb\u5165\u5230<code>bin<\/code> \u76ee\u5f55\uff0c\u6267\u884c\u5982\u4e0b\u547d\u4ee4<\/p>\n<pre><code class=\"language-shell\">C:\\Program Files\\PostgreSQL\\pgsql\\bin&gt;pg_ctl --help\n<\/code><\/pre>\n<p>\u5982\u679c\u6210\u529f\u6267\u884c\u4e0d\u62a5\u9519\uff0c\u5e76\u4e14\u8f93\u51fa\u5982\u4e0b\uff0c\u5219\u8bf4\u660e\u672c\u673a\u4e0d\u7f3a\u5c11\u4f9d\u8d56\u5305\u3002<\/p>\n<p><code>\u6ce8\u610f\uff1acmd\u5fc5\u987b\u4ee5\u7ba1\u7406\u5458\u8eab\u4efd\u8fd0\u884c<\/code><\/p>\n<p><img src=\"https:\/\/lemon-guess.oss-cn-hangzhou.aliyuncs.com\/img\/202209060955503.png\" alt=\"\" \/><\/p>\n<p>\u5982\u679c\u51fa\u73b0\u62a5\u9519\uff0c\u63d0\u793a\u7f3a\u5c11xxx\uff0c\u8bf7\u5b89\u88c5vc\u7684\u8fd0\u884c\u7ec4\u4ef6\u540e\u518d\u6b21\u5c1d\u8bd5\u3002<\/p>\n<p><code>vc_redist.x86.vc2015.14.0.23026.exe<\/code><\/p>\n<p>\u4e0b\u8f7d\u94fe\u63a5\uff1a<\/p>\n<p><code>https:\/\/support.microsoft.com\/en-us\/help\/2977003\/the-latest-supported-visual-c-downloads<\/code><\/p>\n<h2>3\u3001\u521b\u5efa\u5e76\u521d\u59cb\u5316\u6570\u636e\u76ee\u5f55<\/h2>\n<h3>\u521b\u5efa\u6570\u636e\u76ee\u5f55<\/h3>\n<p>\u6211\u7684\u73af\u5883\u6570\u636e\u76ee\u5f55\u4f4d\u4e8e\uff1a <code>D:\\PGData<\/code>\uff0c\u5df2\u7ecf\u63d0\u524d\u65b0\u5efa\u6b64\u76ee\u5f55\uff0c\u786e\u4fdd\u6b64\u76ee\u5f55\u5b58\u5728<\/p>\n<h3>\u521d\u59cb\u5316\u6570\u636e\u76ee\u5f55<\/h3>\n<p>\u6307\u5b9a\u8d85\u7ea7\u7ba1\u7406\u5458\u7528\u6237\u540d\uff1a<code>postgres<\/code>\uff0c\u901a\u8fc7cmd\u547d\u4ee4\u7a97\u53e3\u8fdb\u5165\u5230<code>bin<\/code> \u76ee\u5f55\uff0c\u6267\u884c\u5982\u4e0b\u547d\u4ee4\uff0c<\/p>\n<pre><code>C:\\Program Files\\PostgreSQL\\pgsql\\bin&gt;initdb -D &quot;D:\\PGData&quot; -E UTF-8 --locale=chs -U postgres -W\n\ninitdb -D &quot;E:\\pgsql\\data&quot; -E UTF-8 --locale=chs -U postgres -W<\/code><\/pre>\n<p>\u6267\u884c\u6210\u529f\u540e\u5982\u4e0b\u56fe\uff1a<\/p>\n<p><img src=\"https:\/\/lemon-guess.oss-cn-hangzhou.aliyuncs.com\/img\/202209060955994.png\" alt=\"\" \/><\/p>\n<p>\u901a\u8fc7 <code>-W<\/code> \u53c2\u6570\u4f1a\u63d0\u793a\u8f93\u5165\u8d85\u7ea7\u7528\u6237\u5bc6\u7801<\/p>\n<p>\u6ce8\u610f\u6743\u9650\u95ee\u9898\uff0c\u5982\u679c\u6570\u636e\u76ee\u5f55\u662f\u5728c\u76d8\uff0c\u5219\u9700\u8981\u7ed9user\u6dfb\u52a0\u5b8c\u5168\u63a7\u5236\u6743\u9650<\/p>\n<blockquote>\n<p>\u6211\u6d4b\u8bd5\u7684<\/p>\n<\/blockquote>\n<pre><code class=\"language-shell\">C:\\Users\\zzh\\Desktop\\pgsql\\bin&gt;initdb.exe -D C:\\Users\\zzh\\Desktop\\pgsql\\data -E UTF-8 --locale=chs -U postgres -W\n\u5c5e\u4e8e\u6b64\u6570\u636e\u5e93\u7cfb\u7edf\u7684\u6587\u4ef6\u5bbf\u4e3b\u4e3a\u7528\u6237 &quot;zzh&quot;.\n\u6b64\u7528\u6237\u4e5f\u5fc5\u987b\u4e3a\u670d\u52a1\u5668\u8fdb\u7a0b\u7684\u5bbf\u4e3b.\n\u6570\u636e\u5e93\u7c07\u5c06\u4f7f\u7528\u672c\u5730\u5316\u8bed\u8a00 &quot;Chinese_China.936&quot;\u8fdb\u884c\u521d\u59cb\u5316.\ninitdb: \u65e0\u6cd5\u4e3a\u672c\u5730\u5316\u8bed\u8a00\u73af\u5883&quot;Chinese_China.936&quot;\u627e\u5230\u5408\u9002\u7684\u6587\u672c\u641c\u7d22\u914d\u7f6e\n\u7f3a\u7701\u7684\u6587\u672c\u641c\u7d22\u914d\u7f6e\u5c06\u4f1a\u88ab\u8bbe\u7f6e\u5230&quot;simple&quot;\n\n\u7981\u6b62\u4e3a\u6570\u636e\u9875\u751f\u6210\u6821\u9a8c\u548c.\n\n\u8f93\u5165\u65b0\u7684\u8d85\u7ea7\u7528\u6237\u53e3\u4ee4:123456\n\u518d\u8f93\u5165\u4e00\u904d:123456\n\n\u4fee\u590d\u5df2\u5b58\u5728\u76ee\u5f55 C:\/Users\/zzh\/Desktop\/pgsql\/data \u7684\u6743\u9650 ... \u6210\u529f\n\u6b63\u5728\u521b\u5efa\u5b50\u76ee\u5f55 ... \u6210\u529f\n\u9009\u62e9\u52a8\u6001\u5171\u4eab\u5185\u5b58\u5b9e\u73b0 ......windows\n\u9009\u62e9\u9ed8\u8ba4\u6700\u5927\u8054\u63a5\u6570 (max_connections) ... 100\n\u9009\u62e9\u9ed8\u8ba4\u5171\u4eab\u7f13\u51b2\u533a\u5927\u5c0f (shared_buffers) ... 128MB\n\u9009\u62e9\u9ed8\u8ba4\u65f6\u533a ... Asia\/Shanghai\n\u521b\u5efa\u914d\u7f6e\u6587\u4ef6 ... \u6210\u529f\n\u6b63\u5728\u8fd0\u884c\u81ea\u4e3e\u811a\u672c ...\u6210\u529f\n\u6b63\u5728\u6267\u884c\u81ea\u4e3e\u540e\u521d\u59cb\u5316 ...\u6210\u529f\n\u540c\u6b65\u6570\u636e\u5230\u78c1\u76d8...\u6210\u529f\n\ninitdb: \u8b66\u544a: \u4e3a\u672c\u5730\u8fde\u63a5\u542f\u7528&quot;trust&quot;\u8eab\u4efd\u9a8c\u8bc1\n\u4f60\u53ef\u4ee5\u901a\u8fc7\u7f16\u8f91 pg_hba.conf \u66f4\u6539\u6216\u4f60\u4e0b\u6b21\n\u6267\u884c initdb \u65f6\u4f7f\u7528 -A\u6216\u8005--auth-local\u548c--auth-host\u9009\u9879.\n\n\u6210\u529f\u3002\u60a8\u73b0\u5728\u53ef\u4ee5\u7528\u4e0b\u9762\u7684\u547d\u4ee4\u5f00\u542f\u6570\u636e\u5e93\u670d\u52a1\u5668\uff1a\n\n    pg_ctl -D ^&quot;C^:^\\Users^\\zzh^\\Desktop^\\pgsql^\\data^&quot; -l \u65e5\u5fd7\u6587\u4ef6 start\n\nC:\\Users\\zzh\\Desktop\\pgsql\\bin&gt;<\/code><\/pre>\n<pre><code>pg_ctl -D &quot;D:\\SoftWare\\postgresql-14.5-1-windows-x64-binaries\\pgsql\\data&quot; -l \u65e5\u5fd7\u6587\u4ef6 start<\/code><\/pre>\n<h2>5\u3001\u914d\u7f6epostgres\u6570\u636e\u5e93<\/h2>\n<p>\u914d\u7f6e\u6587\u4ef6\u4f4d\u4e8e\u6570\u636e\u76ee\u5f55\uff1a<code>D:\\PGData<\/code>\uff0c\u5982\u4e0b\u56fe<\/p>\n<p><img src=\"https:\/\/lemon-guess.oss-cn-hangzhou.aliyuncs.com\/img\/202209060955882.png\" alt=\"\" \/><\/p>\n<h3>\u6253\u5f00\u5e76\u4fee\u6539postgresql.conf<\/h3>\n<p>\u901a\u8fc7\u6587\u672c\u7f16\u8f91\u5de5\u5177\uff0c\u6253\u5f00postgresql.conf\uff0c\u4fee\u6539<code>listen_addresses<\/code>\u53c2\u6570<\/p>\n<p>\u4fee\u6539\u524d\uff1a<\/p>\n<p><img src=\"https:\/\/lemon-guess.oss-cn-hangzhou.aliyuncs.com\/img\/202209060956117.png\" alt=\"\" \/><\/p>\n<p>\u4fee\u6539\u540e\uff1a<\/p>\n<p><img src=\"https:\/\/lemon-guess.oss-cn-hangzhou.aliyuncs.com\/img\/202209060956226.png\" alt=\"\" \/><\/p>\n<h3>\u6253\u5f00\u5e76\u4fee\u6539pg_hba.conf<\/h3>\n<p>\u901a\u8fc7\u6587\u672c\u7f16\u8f91\u5de5\u5177\uff0c\u6253\u5f00postgresql.conf\uff0c\u65b0\u589e\u4e00\u6761\u6388\u6743\uff0c\u5141\u8bb8\u901a\u8fc7\u8fdc\u7a0b\u4e3b\u673a\uff08\u4e0d\u9650\u5236IP\uff09\uff0c\u901a\u8fc7\u52a0\u5bc6\u5bc6\u7801\u7684\u65b9\u5f0f\u8fdb\u884c\u6570\u636e\u5e93\u8bbf\u95ee<\/p>\n<p><img src=\"https:\/\/lemon-guess.oss-cn-hangzhou.aliyuncs.com\/img\/202209060956832.png\" alt=\"\" \/><\/p>\n<p>\u4fee\u6539\u4e4b\u540e\uff0c\u5982\u4e0b\u56fe\uff1a<\/p>\n<p><img src=\"https:\/\/lemon-guess.oss-cn-hangzhou.aliyuncs.com\/img\/202209060956808.png\" alt=\"\" \/><\/p>\n<h2>4\u3001\u5b89\u88c5\u670d\u52a1<\/h2>\n<p>\u4ee5\u7ba1\u7406\u5458\u8eab\u4efd\u8fdb\u5165\u5230<code>C:\\Program Files\\PostgreSQL\\pgsql\\bin<\/code> \u76ee\u5f55\uff0c\u8fd0\u884c\u547d\u4ee4\u5c06\u6570\u636e\u5e93\u4ee5windows\u670d\u52a1\u7684\u65b9\u5f0f\u8fd0\u884c\u7ba1\u7406\uff1a<\/p>\n<pre><code class=\"language-shell\">C:\\Program Files\\PostgreSQL\\pgsql\\bin\\pg_ctl register -D &quot;D:\\PGData&quot; -N postgresql-12_1_3-x64 -S auto -U &quot;NT AUTHORITYLocalService&quot;\n<\/code><\/pre>\n<p>\u8d26\u6237\u6743\u9650\u8bf4\u660e\uff1a<\/p>\n<table>\n<thead>\n<tr>\n<th>\u8d26\u6237\u540d\u79f0<\/th>\n<th>\u8d26\u6237\u6807\u8bc6<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>\u672c\u5730\u670d\u52a1<\/td>\n<td>NT AUTHORITYLocalService<\/td>\n<\/tr>\n<tr>\n<td>\u7f51\u7edc\u670d\u52a1<\/td>\n<td>NT AUTHORITYNetworkService<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u5b89\u88c5\u6210\u529f\u540e\u5982\u4e0b\u56fe\uff1a<\/p>\n<p><img src=\"https:\/\/lemon-guess.oss-cn-hangzhou.aliyuncs.com\/img\/202209060956373.png\" alt=\"\" \/><\/p>\n<p>\u7136\u540e\u8fdb\u5165windows\u670d\u52a1\u7ba1\u7406\u5668\uff0c\u542f\u52a8\u670d\u52a1\uff1a<\/p>\n<p><img src=\"https:\/\/lemon-guess.oss-cn-hangzhou.aliyuncs.com\/img\/202209060956489.png\" alt=\"\" \/><\/p>\n<p>\u82e5\u670d\u52a1\u542f\u52a8\u5931\u8d25\uff0c\u6216\u8005\u9700\u8981\u66f4\u6362\u6570\u636e\u5b58\u653e\u76ee\u5f55\u53ef\u4ee5\u53d6\u6d88\u6ce8\u518c\u670d\u52a1\uff1a<\/p>\n<pre><code>C:\\Program Files\\PostgreSQL\\pgsql\\bin\\pg_ctl unregister -N postgresql-12_1_3-x64\n<\/code><\/pre>\n<h2>6\u3001\u521b\u5efa\u7528\u6237\u3001\u6570\u636e\u5e93<\/h2>\n<h3>\u8fde\u63a5\u6570\u636e\u5e93<\/h3>\n<p>\u6253\u5f00cmd\u7a97\u53e3\uff0c\u901a\u8fc7psql\u7ec8\u7aef\u6d4b\u8bd5\u6570\u636e\u5e93\u662f\u5426\u53ef\u7528\uff0c\u4f7f\u7528\u8d85\u7ea7\u7528\u6237<code>postgres<\/code>\u8fde\u63a5\u9ed8\u8ba4\u7684<code>postgres<\/code>\u6570\u636e\u5e93\uff0c\u6267\u884c\u5982\u4e0b\u547d\u4ee4\uff1a<\/p>\n<pre><code>C:\\Usersadmin&gt;psql -d postgres -U postgres\n<\/code><\/pre>\n<p>\u8fde\u63a5\u6210\u529f\u540e\u5982\u4e0b\u56fe\uff1a<\/p>\n<p><img src=\"https:\/\/lemon-guess.oss-cn-hangzhou.aliyuncs.com\/img\/202209060956455.png\" alt=\"\" \/><\/p>\n<h3>\u521b\u5efa\u7528\u6237\u3001\u6570\u636e\u5e93<\/h3>\n<ul>\n<li>\u521b\u5efa\u7528\u6237<\/li>\n<\/ul>\n<pre><code>CREATE USER dba WITH PASSWORD &#039;dba&#039; SUPERUSER;\n<\/code><\/pre>\n<p><img src=\"https:\/\/lemon-guess.oss-cn-hangzhou.aliyuncs.com\/img\/202209060956802.png\" alt=\"\" \/><\/p>\n<ul>\n<li>\u521b\u5efa\u6570\u636e\u5e93<\/li>\n<\/ul>\n<pre><code>CREATE DATABASE exampledb OWNER dba;\n<\/code><\/pre>\n<p><img src=\"https:\/\/lemon-guess.oss-cn-hangzhou.aliyuncs.com\/img\/202209060956039.png\" alt=\"\" \/><\/p>\n<ul>\n<li>\u5207\u6362\u7528\u6237\u53ca\u6570\u636e\u5e93<\/li>\n<\/ul>\n<pre><code>\\c exampledb dba;\n<\/code><\/pre>\n<p><img src=\"https:\/\/lemon-guess.oss-cn-hangzhou.aliyuncs.com\/img\/202209060956837.png\" alt=\"\" \/><\/p>\n<p>\u5230\u6b64\uff0cpostgres\u6570\u636e\u5e93\u7684\u642d\u5efa\u5df2\u7ecf\u5b8c\u6210\uff0c\u63a5\u4e0b\u6765\u53ef\u4ee5\u6109\u5feb\u7684\u4f7f\u7528\u4e86\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4ee5windows\u670d\u52a1\u65b9\u5f0f\u5feb\u901f\u90e8\u7f72\u514d\u5b89\u88c5\u7248Postgres\u6570\u636e\u5e93 1\u3001\u4e0b\u8f7dPostgresql\u6570\u636e\u5e93\u514d\u5b89\u88c5\u5305 \u4e0b\u8f7d\u5730\u5740 https:\/\/w   \u2026 &#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"ngg_post_thumbnail":0},"categories":[36],"tags":[91],"_links":{"self":[{"href":"\/index.php?rest_route=\/wp\/v2\/posts\/1291"}],"collection":[{"href":"\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1291"}],"version-history":[{"count":1,"href":"\/index.php?rest_route=\/wp\/v2\/posts\/1291\/revisions"}],"predecessor-version":[{"id":1292,"href":"\/index.php?rest_route=\/wp\/v2\/posts\/1291\/revisions\/1292"}],"wp:attachment":[{"href":"\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1291"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1291"},{"taxonomy":"post_tag","embeddable":true,"href":"\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1291"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}