{"id":166027,"date":"2024-11-05T15:07:41","date_gmt":"2024-11-05T07:07:41","guid":{"rendered":"https:\/\/server.hk\/cnblog\/166027\/"},"modified":"2024-11-05T15:07:42","modified_gmt":"2024-11-05T07:07:42","slug":"%e5%bf%ab%e9%80%9f%e8%a7%a3%e6%b1%ba%e5%95%8f%e9%a1%8c%ef%bc%81%e6%95%99%e4%bd%a0%e5%a6%82%e4%bd%95%e9%87%8d%e6%96%b0%e5%95%9f%e5%8b%95postgresql%e6%95%b8%e6%93%9a%e5%ba%ab-postgresql%e6%95%b8","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/166027\/","title":{"rendered":"\u5feb\u901f\u89e3\u6c7a\u554f\u984c\uff01\u6559\u4f60\u5982\u4f55\u91cd\u65b0\u555f\u52d5postgresql\u6578\u64da\u5eab (postgresql\u6578\u64da\u5eab\u91cd\u555f)"},"content":{"rendered":"<h1 id=\"%e5%bf%ab%e9%80%9f%e8%a7%a3%e6%b1%ba%e5%95%8f%e9%a1%8c%ef%bc%81%e6%95%99%e4%bd%a0%e5%a6%82%e4%bd%95%e9%87%8d%e6%96%b0%e5%95%9f%e5%8b%95postgresql%e6%95%b8%e6%93%9a%e5%ba%ab-ZgkoovymOj\">\u5feb\u901f\u89e3\u6c7a\u554f\u984c\uff01\u6559\u4f60\u5982\u4f55\u91cd\u65b0\u555f\u52d5PostgreSQL\u6578\u64da\u5eab<\/h1>\n<p>\u5728\u65e5\u5e38\u7684\u6578\u64da\u5eab\u7ba1\u7406\u4e2d\uff0cPostgreSQL\u4f5c\u70ba\u4e00\u500b\u5f37\u5927\u7684\u958b\u6e90\u6578\u64da\u5eab\u7cfb\u7d71\uff0c\u7d93\u5e38\u9700\u8981\u9032\u884c\u91cd\u555f\u64cd\u4f5c\u4ee5\u89e3\u6c7a\u5404\u7a2e\u554f\u984c\uff0c\u4f8b\u5982\u6027\u80fd\u4e0b\u964d\u3001\u914d\u7f6e\u66f4\u6539\u6216\u662f\u61c9\u7528\u7a0b\u5e8f\u932f\u8aa4\u7b49\u3002\u672c\u6587\u5c07\u8a73\u7d30\u4ecb\u7d39\u5982\u4f55\u5b89\u5168\u4e14\u6709\u6548\u5730\u91cd\u65b0\u555f\u52d5PostgreSQL\u6578\u64da\u5eab\uff0c\u5e6b\u52a9\u4f60\u5feb\u901f\u89e3\u6c7a\u554f\u984c\u3002<\/p>\n<h2 id=\"%e7%82%ba%e4%bb%80%e9%ba%bc%e9%9c%80%e8%a6%81%e9%87%8d%e6%96%b0%e5%95%9f%e5%8b%95postgresql%e6%95%b8%e6%93%9a%e5%ba%ab%ef%bc%9f-ZgkoovymOj\">\u70ba\u4ec0\u9ebc\u9700\u8981\u91cd\u65b0\u555f\u52d5PostgreSQL\u6578\u64da\u5eab\uff1f<\/h2>\n<p>\u91cd\u65b0\u555f\u52d5PostgreSQL\u6578\u64da\u5eab\u7684\u539f\u56e0\u6709\u5f88\u591a\uff0c\u4ee5\u4e0b\u662f\u4e00\u4e9b\u5e38\u898b\u7684\u60c5\u6cc1\uff1a<\/p>\n<ul>\n<li><strong>\u914d\u7f6e\u66f4\u6539\uff1a<\/strong>\u7576\u4f60\u4fee\u6539\u4e86PostgreSQL\u7684\u914d\u7f6e\u6587\u4ef6\uff08\u5982postgresql.conf\uff09\u5f8c\uff0c\u901a\u5e38\u9700\u8981\u91cd\u555f\u6578\u64da\u5eab\u4ee5\u4f7f\u66f4\u6539\u751f\u6548\u3002<\/li>\n<li><strong>\u6027\u80fd\u554f\u984c\uff1a<\/strong>\u5982\u679c\u6578\u64da\u5eab\u904b\u884c\u7de9\u6162\uff0c\u91cd\u555f\u53ef\u80fd\u6703\u91cb\u653e\u8cc7\u6e90\u4e26\u6539\u5584\u6027\u80fd\u3002<\/li>\n<li><strong>\u61c9\u7528\u7a0b\u5e8f\u932f\u8aa4\uff1a<\/strong>\u67d0\u4e9b\u61c9\u7528\u7a0b\u5e8f\u53ef\u80fd\u6703\u5c0e\u81f4\u6578\u64da\u5eab\u9032\u5165\u4e0d\u7a69\u5b9a\u72c0\u614b\uff0c\u91cd\u555f\u53ef\u4ee5\u6062\u5fa9\u6b63\u5e38\u904b\u884c\u3002<\/li>\n<\/ul>\n<h2 id=\"%e5%a6%82%e4%bd%95%e9%87%8d%e6%96%b0%e5%95%9f%e5%8b%95postgresql%e6%95%b8%e6%93%9a%e5%ba%ab-ZgkoovymOj\">\u5982\u4f55\u91cd\u65b0\u555f\u52d5PostgreSQL\u6578\u64da\u5eab<\/h2>\n<p>\u5728\u91cd\u65b0\u555f\u52d5PostgreSQL\u6578\u64da\u5eab\u4e4b\u524d\uff0c\u5efa\u8b70\u5148\u5099\u4efd\u91cd\u8981\u6578\u64da\uff0c\u4ee5\u9632\u6b62\u610f\u5916\u60c5\u6cc1\u5c0e\u81f4\u6578\u64da\u4e1f\u5931\u3002\u4ee5\u4e0b\u662f\u91cd\u65b0\u555f\u52d5\u7684\u6b65\u9a5f\uff1a<\/p>\n<h3 id=\"1-%e4%bd%bf%e7%94%a8%e5%91%bd%e4%bb%a4%e8%a1%8c%e5%b7%a5%e5%85%b7-ZgkoovymOj\">1. \u4f7f\u7528\u547d\u4ee4\u884c\u5de5\u5177<\/h3>\n<p>\u5728\u5927\u591a\u6578Linux\u7cfb\u7d71\u4e2d\uff0c\u4f60\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u4f86\u91cd\u65b0\u555f\u52d5PostgreSQL\u6578\u64da\u5eab\uff1a<\/p>\n<pre><code>sudo systemctl restart postgresql<\/code><\/pre>\n<p>\u9019\u689d\u547d\u4ee4\u6703\u505c\u6b62PostgreSQL\u670d\u52d9\uff0c\u7136\u5f8c\u518d\u555f\u52d5\u5b83\u3002\u4f60\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u4f86\u6aa2\u67e5\u670d\u52d9\u7684\u72c0\u614b\uff1a<\/p>\n<pre><code>sudo systemctl status postgresql<\/code><\/pre>\n<h3 id=\"2-%e4%bd%bf%e7%94%a8pg_ctl%e5%91%bd%e4%bb%a4-ZgkoovymOj\">2. \u4f7f\u7528pg_ctl\u547d\u4ee4<\/h3>\n<p>\u53e6\u4e00\u7a2e\u65b9\u6cd5\u662f\u4f7f\u7528PostgreSQL\u81ea\u5e36\u7684pg_ctl\u547d\u4ee4\u3002\u9019\u7a2e\u65b9\u6cd5\u9069\u5408\u9700\u8981\u66f4\u7d30\u7dfb\u63a7\u5236\u7684\u60c5\u6cc1\uff1a<\/p>\n<pre><code>pg_ctl -D \/path\/to\/your\/data\/directory restart<\/code><\/pre>\n<p>\u5728\u9019\u88e1\uff0c<code>\/path\/to\/your\/data\/directory<\/code>\u662f\u4f60\u7684PostgreSQL\u6578\u64da\u76ee\u9304\u7684\u8def\u5f91\u3002\u9019\u500b\u547d\u4ee4\u6703\u5b89\u5168\u5730\u505c\u6b62\u4e26\u91cd\u65b0\u555f\u52d5\u6578\u64da\u5eab\u3002<\/p>\n<h3 id=\"3-%e4%bd%bf%e7%94%a8sql%e5%91%bd%e4%bb%a4-ZgkoovymOj\">3. \u4f7f\u7528SQL\u547d\u4ee4<\/h3>\n<p>\u5982\u679c\u4f60\u5df2\u7d93\u9023\u63a5\u5230PostgreSQL\u6578\u64da\u5eab\uff0c\u4f60\u4e5f\u53ef\u4ee5\u4f7f\u7528SQL\u547d\u4ee4\u4f86\u91cd\u65b0\u555f\u52d5\u670d\u52d9\u3002\u9019\u9700\u8981\u8d85\u7d1a\u7528\u6236\u6b0a\u9650\uff1a<\/p>\n<pre><code>SELECT pg_terminate_backend(pid) FROM pg_stat_activity WHERE datname = 'your_database_name';<\/code><\/pre>\n<p>\u9019\u689d\u547d\u4ee4\u6703\u7d42\u6b62\u6240\u6709\u9023\u63a5\u5230\u6307\u5b9a\u6578\u64da\u5eab\u7684\u6703\u8a71\uff0c\u7136\u5f8c\u4f60\u53ef\u4ee5\u624b\u52d5\u91cd\u555f\u670d\u52d9\u3002<\/p>\n<h2 id=\"%e6%b3%a8%e6%84%8f%e4%ba%8b%e9%a0%85-ZgkoovymOj\">\u6ce8\u610f\u4e8b\u9805<\/h2>\n<p>\u5728\u91cd\u65b0\u555f\u52d5PostgreSQL\u6578\u64da\u5eab\u6642\uff0c\u8acb\u6ce8\u610f\u4ee5\u4e0b\u5e7e\u9ede\uff1a<\/p>\n<ul>\n<li>\u78ba\u4fdd\u6c92\u6709\u91cd\u8981\u7684\u4e8b\u52d9\u6b63\u5728\u9032\u884c\uff0c\u56e0\u70ba\u91cd\u555f\u6703\u4e2d\u65b7\u6240\u6709\u7576\u524d\u9023\u63a5\u3002<\/li>\n<li>\u5728\u9ad8\u53ef\u7528\u6027\u74b0\u5883\u4e2d\uff0c\u8003\u616e\u4f7f\u7528\u8ca0\u8f09\u5747\u8861\u5668\u4f86\u6e1b\u5c11\u5c0d\u7528\u6236\u7684\u5f71\u97ff\u3002<\/li>\n<li>\u6aa2\u67e5\u65e5\u8a8c\u6587\u4ef6\u4ee5\u78ba\u4fdd\u91cd\u555f\u904e\u7a0b\u4e2d\u6c92\u6709\u932f\u8aa4\u767c\u751f\u3002<\/li>\n<\/ul>\n<h2 id=\"%e7%b8%bd%e7%b5%90-ZgkoovymOj\">\u7e3d\u7d50<\/h2>\n<p>\u91cd\u65b0\u555f\u52d5PostgreSQL\u6578\u64da\u5eab\u662f\u4e00\u9805\u91cd\u8981\u7684\u7ba1\u7406\u4efb\u52d9\uff0c\u53ef\u4ee5\u5e6b\u52a9\u89e3\u6c7a\u591a\u7a2e\u554f\u984c\u3002\u7121\u8ad6\u662f\u901a\u904e\u547d\u4ee4\u884c\u5de5\u5177\u3001pg_ctl\u547d\u4ee4\u9084\u662fSQL\u547d\u4ee4\uff0c\u4e86\u89e3\u5982\u4f55\u6b63\u78ba\u5730\u9032\u884c\u91cd\u555f\u90fd\u662f\u6bcf\u4f4d\u6578\u64da\u5eab\u7ba1\u7406\u54e1\u5fc5\u5099\u7684\u6280\u80fd\u3002\u5982\u679c\u4f60\u9700\u8981\u66f4\u9ad8\u6548\u7684\u6578\u64da\u5eab\u7ba1\u7406\u89e3\u6c7a\u65b9\u6848\uff0c\u8003\u616e\u4f7f\u7528<a href=\"https:\/\/server.hk\">\u9999\u6e2fVPS<\/a>\u6216<a href=\"https:\/\/server.hk\">\u9999\u6e2f\u4f3a\u670d\u5668<\/a>\u4f86\u63d0\u5347\u4f60\u7684\u696d\u52d9\u904b\u884c\u6548\u7387\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5feb\u901f\u89e3\u6c7a\u554f\u984c\uff01\u5b78\u7fd2\u5982\u4f55\u8f15\u9b06\u91cd\u65b0\u555f\u52d5PostgreSQL\u6578\u64da\u5eab\uff0c\u78ba\u4fdd\u6578\u64da\u5b89\u5168\u8207\u7cfb\u7d71\u7a69\u5b9a\u3002<\/p>\n","protected":false},"author":0,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[101],"tags":[],"class_list":["post-166027","post","type-post","status-publish","format-standard","hentry","category-database"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/166027","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/types\/post"}],"replies":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/comments?post=166027"}],"version-history":[{"count":1,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/166027\/revisions"}],"predecessor-version":[{"id":166028,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/166027\/revisions\/166028"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=166027"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=166027"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=166027"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}