{"id":22664,"date":"2021-03-14T03:59:08","date_gmt":"2021-03-13T19:59:08","guid":{"rendered":"http:\/\/www.idc.net\/help\/22664\/"},"modified":"2022-04-29T14:34:13","modified_gmt":"2022-04-29T06:34:13","slug":"ubuntu%e5%ae%89%e8%a3%85postgresql%e6%95%b0%e6%8d%ae%e5%ba%93","status":"publish","type":"post","link":"https:\/\/idc.net\/help\/22664\/","title":{"rendered":"Ubuntu\u5b89\u88c5PostgreSQL\u6570\u636e\u5e93"},"content":{"rendered":"<div class=\"idc_table\">\n<p style=\"padding-top: 8px;padding-bottom: 8px;margin: 5px 0px;line-height: 1.75;letter-spacing: 0.1em;font-size: 16px;text-align: justify\">PostgreSQL\u662f\u4e00\u6b3e\u529f\u80fd\u5f3a\u5927\u7684\u5f00\u6e90\u5bf9\u8c61\u5173\u7cfb\u578b\u6570\u636e\u5e93\u7cfb\u7edf\uff0c\u6e90\u7801\u5f00\u653e\uff0c\u7531\u793e\u533a\u5171\u540c\u7ef4\u62a4\uff0c\u4e0d\u53d7\u4efb\u4f55\u516c\u53f8\u548c\u4e2a\u4eba\u63a7\u5236\uff0c\u53ef\u4ee5\u514d\u8d39\u4f7f\u7528\u3002<\/p>\n<p><img decoding=\"async\" style=\"max-width: 100%;border-radius: 5px 5px 5px 5px;margin: 0px 10px auto;width: 100%;height: 100%\" src=\"https:\/\/lxlinux.superbed.verylink.top\/item\/618f6c952ab3f51d914f2b25.png\" class=\"aligncenter\">  <\/p>\n<h3><span style=\"font-size: 18px;color: #f48a00;padding-left: 10px;border-left: 4px solid #ffe3a3\">\u5b9e\u9a8c\u73af\u5883<\/span><\/h3>\n<p style=\"padding-top: 8px;padding-bottom: 8px;margin: 5px 0px;line-height: 1.75;letter-spacing: 0.1em;font-size: 16px;text-align: justify\">\u64cd\u4f5c\u7cfb\u7edf\uff1aUbuntu 20.04<\/p>\n<p style=\"padding-top: 8px;padding-bottom: 8px;margin: 5px 0px;line-height: 1.75;letter-spacing: 0.1em;font-size: 16px;text-align: justify\">\u4ee5root\u6216\u5177\u6709sudo\u6743\u9650\u7684\u7528\u6237\u8eab\u4efd\u6267\u884c\u5b89\u88c5<\/p>\n<h3><span style=\"font-size: 18px;color: #f48a00;padding-left: 10px;border-left: 4px solid #ffe3a3\">\u5728Ubuntu\u4e0a\u5b89\u88c5PostgreSQL<\/span><\/h3>\n<p style=\"padding-top: 8px;padding-bottom: 8px;margin: 5px 0px;line-height: 1.75;letter-spacing: 0.1em;font-size: 16px;text-align: justify\">\u5728Ubuntu\u4e0a\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\u6765\u5b89\u88c5PostgreSQL\u670d\u52a1\u5668\u3002<\/p>\n<pre><code>root@linuxcool:~<span style=\"color: #57a64a;font-style: italic;line-height: 26px\">#&nbsp;sudo&nbsp;apt&nbsp;update<\/span>\r\nroot@linuxcool:~<span style=\"color: #57a64a;font-style: italic;line-height: 26px\">#&nbsp;sudo&nbsp;apt&nbsp;install&nbsp;postgresql&nbsp;postgresql-contrib<\/span>\r\n<\/code><\/pre>\n<p><img decoding=\"async\" style=\"max-width: 100%;border-radius: 5px 5px 5px 5px;margin: 0px 10px auto;width: 100%;height: 100%\" src=\"https:\/\/lxlinux.superbed.verylink.top\/item\/618f6c972ab3f51d914f2c54.png\" class=\"aligncenter\">  <\/p>\n<p style=\"padding-top: 8px;padding-bottom: 8px;margin: 5px 0px;line-height: 1.75;letter-spacing: 0.1em;font-size: 16px;text-align: justify\">\u5b89\u88c5\u5b8c\u6210\u540e\uff0cPostgreSQL\u670d\u52a1\u4f1a\u81ea\u52a8\u542f\u52a8\uff0c\u4f7f\u7528psql\u5de5\u5177\u8fde\u63a5\u5230PostgreSQL\u6570\u636e\u5e93\u670d\u52a1\u5668\u5e76\u6253\u5370\u51fa\u5176\u7248\u672c\u6765\u9a8c\u8bc1\u5b89\u88c5\u60c5\u51b5\u3002<\/p>\n<h3><span style=\"font-size: 18px;color: #f48a00;padding-left: 10px;border-left: 4px solid #ffe3a3\">\u67e5\u770bPostgreSQL\u670d\u52a1\u72b6\u6001<\/span><\/h3>\n<pre><code>root@linuxcool:~<span style=\"color: #57a64a;font-style: italic;line-height: 26px\">#&nbsp;systemctl&nbsp;status&nbsp;postgresql<\/span>\r\n<\/code><\/pre>\n<p><img decoding=\"async\" style=\"max-width: 100%;border-radius: 5px 5px 5px 5px;margin: 0px 10px auto;width: 100%;height: 100%\" src=\"https:\/\/lxlinux.superbed.verylink.top\/item\/618f6c962ab3f51d914f2b3e.png\" class=\"aligncenter\">  <\/p>\n<h3><span style=\"font-size: 18px;color: #f48a00;padding-left: 10px;border-left: 4px solid #ffe3a3\">\u67e5\u770bPostgreSQL\u7248\u672c\u53f7<\/span><\/h3>\n<pre><code>root@linuxcool:~<span style=\"color: #57a64a;font-style: italic;line-height: 26px\">#&nbsp;sudo&nbsp;-u&nbsp;postgres&nbsp;psql&nbsp;-c&nbsp;\"SELECT&nbsp;version();\"<\/span>\r\n<\/code><\/pre>\n<p><img decoding=\"async\" style=\"max-width: 100%;border-radius: 5px 5px 5px 5px;margin: 0px 10px auto;width: 100%;height: 100%\" src=\"https:\/\/lxlinux.superbed.verylink.top\/item\/618f6c962ab3f51d914f2b98.png\" class=\"aligncenter\">  <\/p>\n<h3><span style=\"font-size: 18px;color: #f48a00;padding-left: 10px;border-left: 4px solid #ffe3a3\">PostgreSQL\u7684\u89d2\u8272\u548c\u8ba4\u8bc1\u65b9\u6cd5<\/span><\/h3>\n<p style=\"padding-top: 8px;padding-bottom: 8px;margin: 5px 0px;line-height: 1.75;letter-spacing: 0.1em;font-size: 16px;text-align: justify\">\u4e0b\u9762\u662fPostgreSQL\u4e0eshell\u4ea4\u4e92\u64cd\u4f5c\uff1a<\/p>\n<pre><code>root@linuxcool:~<span style=\"color: #57a64a;font-style: italic;line-height: 26px\">#&nbsp;sudo&nbsp;su&nbsp;-&nbsp;postgres<\/span>\r\npostgres@linuxcool:~$&nbsp;psql\r\npsql&nbsp;(10.12&nbsp;(Ubuntu&nbsp;10.12-0ubuntu0.18.04.1))\r\nType&nbsp;<span style=\"color: #d69d85;line-height: 26px\">\"help\"<\/span>&nbsp;<span style=\"color: #569cd6;line-height: 26px\">for<\/span>&nbsp;<span style=\"color: #4ec9b0;line-height: 26px\">help<\/span>.\r\n\r\npostgres=<span style=\"color: #57a64a;font-style: italic;line-height: 26px\">#<\/span>\r\n<\/code><\/pre>\n<p><img decoding=\"async\" style=\"max-width: 100%;border-radius: 5px 5px 5px 5px;margin: 0px 10px auto;width: 100%;height: 100%\" src=\"https:\/\/lxlinux.superbed.verylink.top\/item\/618f6c962ab3f51d914f2b5b.png\" class=\"aligncenter\">  <\/p>\n<p style=\"padding-top: 8px;padding-bottom: 8px;margin: 5px 0px;line-height: 1.75;letter-spacing: 0.1em;font-size: 16px;text-align: justify\">\u9000\u51faPostgreSQL\u7ec8\u7aef\uff1a<\/p>\n<pre><code>postgres=<span style=\"color: #57a64a;font-style: italic;line-height: 26px\">#&nbsp;\\q<\/span>\r\n<\/code><\/pre>\n<p><img decoding=\"async\" style=\"max-width: 100%;border-radius: 5px 5px 5px 5px;margin: 0px 10px auto;width: 100%;height: 100%\" src=\"https:\/\/lxlinux.superbed.verylink.top\/item\/618f6c962ab3f51d914f2b6a.png\" class=\"aligncenter\">  <\/p>\n<h3><span style=\"font-size: 18px;color: #f48a00;padding-left: 10px;border-left: 4px solid #ffe3a3\">\u6267\u884c\u7b80\u5355SQL\u8bed\u53e5<\/span><\/h3>\n<p style=\"padding-top: 8px;padding-bottom: 8px;margin: 5px 0px;line-height: 1.75;letter-spacing: 0.1em;font-size: 16px;text-align: justify\">\u4f7f\u7528\u7ba1\u7406\u5458\u6743\u9650sudo\u547d\u4ee4\u4e0eshell\u4ea4\u4e92\u6267\u884cSQL\u8bed\u53e5\uff0c\u5982\u679c\u666e\u901a\u7528\u6237\u6ca1\u6709\u6743\u9650\uff0c\u9700\u8981\u5207\u6362\u5230root\u7528\u6237\u64cd\u4f5c,\u4e5f\u53ef\u4ee5\u4e0d\u5207\u6362\u7528\u6237\uff0c\u6bcf\u6b21\u6267\u884c\u547d\u4ee4\u63d0\u793a\u8f93\u5165\u5bc6\u7801\u3002<\/p>\n<p style=\"padding-top: 8px;padding-bottom: 8px;margin: 5px 0px;line-height: 1.75;letter-spacing: 0.1em;font-size: 16px;text-align: justify\">\u5207\u6362\u7528\u6237<\/p>\n<pre><code>root@linuxcool:~<span style=\"color: #57a64a;font-style: italic;line-height: 26px\">#&nbsp;su&nbsp;root<\/span>\r\n<\/code><\/pre>\n<p style=\"padding-top: 8px;padding-bottom: 8px;margin: 5px 0px;line-height: 1.75;letter-spacing: 0.1em;font-size: 16px;text-align: justify\">sql\u521b\u5efaDB\u7528\u6237<\/p>\n<pre><code>root@linuxcool:~<span style=\"color: #57a64a;font-style: italic;line-height: 26px\">#&nbsp;sudo&nbsp;su&nbsp;-&nbsp;postgres&nbsp;-c&nbsp;\"createuser&nbsp;linuxprobe\"<\/span>\r\n<\/code><\/pre>\n<p style=\"padding-top: 8px;padding-bottom: 8px;margin: 5px 0px;line-height: 1.75;letter-spacing: 0.1em;font-size: 16px;text-align: justify\">\u521b\u5efa\u6570\u636e\u5e93<\/p>\n<pre><code>root@linuxcool:~<span style=\"color: #57a64a;font-style: italic;line-height: 26px\">#&nbsp;sudo&nbsp;su&nbsp;-&nbsp;postgres&nbsp;-c&nbsp;\"createdb&nbsp;linuxprobe\"<\/span>\r\n<\/code><\/pre>\n<p style=\"padding-top: 8px;padding-bottom: 8px;margin: 5px 0px;line-height: 1.75;letter-spacing: 0.1em;font-size: 16px;text-align: justify\">\u628alinuxprobe\u6570\u636e\u5e93\u6388\u6743\u7ed9linuxprobe\u7528\u6237<\/p>\n<pre><code>root@linuxcool:~<span style=\"color: #57a64a;font-style: italic;line-height: 26px\">#&nbsp;sudo&nbsp;-u&nbsp;postgres&nbsp;psql<\/span>\r\npsql&nbsp;(10.12&nbsp;(Ubuntu&nbsp;10.12-0ubuntu0.18.04.1))\r\nType&nbsp;<span style=\"color: #d69d85;line-height: 26px\">\"help\"<\/span>&nbsp;<span style=\"color: #569cd6;line-height: 26px\">for<\/span>&nbsp;<span style=\"color: #4ec9b0;line-height: 26px\">help<\/span>.\r\n\r\npostgres=<span style=\"color: #57a64a;font-style: italic;line-height: 26px\">#&nbsp;grant&nbsp;all&nbsp;privileges&nbsp;on&nbsp;database&nbsp;linuxprobe&nbsp;to&nbsp;linuxprobe;<\/span>\r\nGRANT\r\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>PostgreSQL\u662f\u4e00\u6b3e\u529f\u80fd\u5f3a\u5927\u7684\u5f00\u6e90\u5bf9\u8c61\u5173\u7cfb\u578b\u6570\u636e\u5e93\u7cfb\u7edf\uff0c\u6e90\u7801\u5f00\u653e\uff0c\u7531\u793e\u533a\u5171\u540c\u7ef4\u62a4\uff0c\u4e0d\u53d7\u4efb\u4f55\u516c\u53f8\u548c\u4e2a\u4eba\u63a7\u5236 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":22665,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[34,28],"tags":[],"class_list":["post-22664","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-linux","category-ubuntu"],"_links":{"self":[{"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/posts\/22664","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/comments?post=22664"}],"version-history":[{"count":0,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/posts\/22664\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/media\/22665"}],"wp:attachment":[{"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/media?parent=22664"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/categories?post=22664"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/tags?post=22664"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}