{"id":25754,"date":"2023-08-28T04:29:33","date_gmt":"2022-12-15T06:11:41","guid":{"rendered":"https:\/\/www.silicloud.com\/zh\/blog\/%e5%9c%a8ubuntu%e4%b8%8a%e5%ae%89%e8%a3%85postgres%e3%80%82-6\/"},"modified":"2025-08-11T16:03:00","modified_gmt":"2025-08-11T08:03:00","slug":"%e5%9c%a8ubuntu%e4%b8%8a%e5%ae%89%e8%a3%85postgres%e3%80%82-6","status":"publish","type":"post","link":"https:\/\/www.silicloud.com\/zh\/blog\/%e5%9c%a8ubuntu%e4%b8%8a%e5%ae%89%e8%a3%85postgres%e3%80%82-6\/","title":{"rendered":"\u5728Ubuntu\u4e0a\u5b89\u88c5Postgres"},"content":{"rendered":"<p>\u521b\u5efapostgres\u7528\u6237<\/p>\n<pre class=\"post-pre\"><code>$ sudo adduser postgres\r\n$ sudo passwd postgres\r\n<\/code><\/pre>\n<p>\u6309\u7167\u516c\u5f0f\u7684\u5927\u81f4\u6b65\u9aa4\u5b89\u88c5\u6700\u65b0\u7248\u672c\u7684PostgreSQL\u3002<br \/>\nhttps:\/\/www.postgresql.org\/download\/linux\/ubuntu\/<\/p>\n<pre class=\"post-pre\"><code># \u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u4e88\u5b9a\u306e\u30d0\u30fc\u30b8\u30e7\u30f3\u3092\u78ba\u8a8d\r\n$ sudo apt info postgresql\r\nPackage: postgresql\r\nVersion: 14+238               # \u53e4\u3044\r\n\r\n# Create the file repository configuration:\r\n$ sudo sh -c 'echo \"deb http:\/\/apt.postgresql.org\/pub\/repos\/apt $(lsb_release -cs)-pgdg main\" &gt; \/etc\/apt\/sources.list.d\/pgdg.list'\r\n\r\n# Import the repository signing key:\r\n$ wget --quiet -O - https:\/\/www.postgresql.org\/media\/keys\/ACCC4CF8.asc | sudo apt-key add -\r\n\r\n# Update the package lists:\r\n$ sudo apt update\r\n\r\n# \u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u4e88\u5b9a\u306e\u30d0\u30fc\u30b8\u30e7\u30f3\u3092\u78ba\u8a8d\r\n$ sudo apt info postgresql\r\nPackage: postgresql\r\nVersion: 15+248.pgdg22.04+1   # \u65b0\u3057\u3044\r\n\r\n# Install the latest version of PostgreSQL.\r\n# If you want a specific version, use 'postgresql-12' or similar instead of 'postgresql':\r\n$ sudo apt -y install postgresql\r\n<\/code><\/pre>\n<p>\u5982\u679c\u5728\u65c5\u9014\u4e2d\u9047\u5230\u4ee5\u4e0b\u9519\u8bef\u7684\u60c5\u51b5<\/p>\n<pre class=\"post-pre\"><code>Setting up postgresql (15+248.pgdg22.04+1) ...\r\nProcessing triggers for man-db (2.10.2-1) ...\r\nProcessing triggers for libc-bin (2.35-0ubuntu3.1) ...\r\nScanning processes...\r\nScanning processor microcode...\r\nScanning linux images...\r\nRunning kernel seems to be up-to-date.\r\nFailed to check for processor microcode upgrades.\r\nNo services need to be restarted.\r\nNo containers need to be restarted.\r\nNo user sessions are running outdated binaries.\r\nNo VM guests are running outdated hypervisor (qemu) binaries on this host.\r\n<\/code><\/pre>\n<p>\u8fd9\u6837\u5c31\u5904\u7406\u4e86<\/p>\n<pre class=\"post-pre\"><code>$ sudo apt -y remove postgresql\r\n$ apt purge needrestart\r\n$ sudo apt -y install postgresql\r\n<\/code><\/pre>\n<p>\u5bfb\u627e\u5b89\u88c5\u4f4d\u7f6e<\/p>\n<pre class=\"post-pre\"><code>$ sudo find \/ -name postgresql\r\n\/var\/log\/postgresql\r\n\/var\/lib\/postgresql\r\n\/usr\/lib\/postgresql\r\n\/usr\/share\/doc\/postgresql\r\n\/usr\/share\/postgresql\r\n\/etc\/postgresql\r\n\/run\/postgresql\r\n<\/code><\/pre>\n<p>\u542f\u52a8PostgreSQL<\/p>\n<pre class=\"post-pre\"><code>$ sudo systemctl enable postgresql\r\n$ sudo systemctl start postgresql\r\n<\/code><\/pre>\n<p>\u6570\u636e\u5e93\u7684\u521d\u59cb\u8bbe\u7f6e<\/p>\n<pre class=\"post-pre\"><code>sudo su - postgres\r\nvi .profile\r\nexport PGHOME=\/usr\/lib\/postgresql\/15\r\nexport PGDATA=\/var\/lib\/postgresql\/15\/data\r\nexport PGLIB=$PGHOME\/lib\r\nexport LD_LIBRARY_PATH=$PGHOME\/lib\r\nexport PATH=$PATH:$PGHOME\/bin\r\n\r\nsource ~\/.profile\r\ninitdb -E UTF8 --no-locale\r\n<\/code><\/pre>\n<p>\u542f\u52a8\u6570\u636e\u5e93<br \/>\n\u4f7f\u7528pg_ctl start\u547d\u4ee4<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u521b\u5efapostgres\u7528\u6237 $ sudo adduser postgres $ sudo passwd post [&hellip;]<\/p>\n","protected":false},"author":4,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[227],"class_list":["post-25754","post","type-post","status-publish","format-standard","hentry","category-uncategorized","tag-227"],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v21.5 (Yoast SEO v21.5) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u5728Ubuntu\u4e0a\u5b89\u88c5Postgres - Blog - Silicon Cloud<\/title>\n<meta name=\"description\" content=\"\u5173\u4e8e\u5728Ubuntu\u4e0a\u5b89\u88c5Postgres\u7684\u6280\u672f\u6587\u7ae0\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.silicloud.com\/zh\/blog\/\u5728ubuntu\u4e0a\u5b89\u88c5postgres\u3002-6\/\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u5728Ubuntu\u4e0a\u5b89\u88c5Postgres\" \/>\n<meta property=\"og:description\" content=\"\u5173\u4e8e\u5728Ubuntu\u4e0a\u5b89\u88c5Postgres\u7684\u6280\u672f\u6587\u7ae0\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.silicloud.com\/zh\/blog\/\u5728ubuntu\u4e0a\u5b89\u88c5postgres\u3002-6\/\" \/>\n<meta property=\"og:site_name\" content=\"Blog - Silicon Cloud\" \/>\n<meta property=\"article:published_time\" content=\"2022-12-15T06:11:41+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-08-11T08:03:00+00:00\" \/>\n<meta name=\"author\" content=\"\u79d1, \u96c5\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"\u79d1, \u96c5\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/%e5%9c%a8ubuntu%e4%b8%8a%e5%ae%89%e8%a3%85postgres%e3%80%82-6\/\",\"url\":\"https:\/\/www.silicloud.com\/zh\/blog\/%e5%9c%a8ubuntu%e4%b8%8a%e5%ae%89%e8%a3%85postgres%e3%80%82-6\/\",\"name\":\"\u5728Ubuntu\u4e0a\u5b89\u88c5Postgres - Blog - Silicon Cloud\",\"isPartOf\":{\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#website\"},\"datePublished\":\"2022-12-15T06:11:41+00:00\",\"dateModified\":\"2025-08-11T08:03:00+00:00\",\"author\":{\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/41e222757cdd2a3365361328bd79970a\"},\"description\":\"\u5173\u4e8e\u5728Ubuntu\u4e0a\u5b89\u88c5Postgres\u7684\u6280\u672f\u6587\u7ae0\",\"breadcrumb\":{\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/%e5%9c%a8ubuntu%e4%b8%8a%e5%ae%89%e8%a3%85postgres%e3%80%82-6\/#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.silicloud.com\/zh\/blog\/%e5%9c%a8ubuntu%e4%b8%8a%e5%ae%89%e8%a3%85postgres%e3%80%82-6\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/%e5%9c%a8ubuntu%e4%b8%8a%e5%ae%89%e8%a3%85postgres%e3%80%82-6\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.silicloud.com\/zh\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u5728Ubuntu\u4e0a\u5b89\u88c5Postgres\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#website\",\"url\":\"https:\/\/www.silicloud.com\/zh\/blog\/\",\"name\":\"Blog - Silicon Cloud\",\"description\":\"\",\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/41e222757cdd2a3365361328bd79970a\",\"name\":\"\u79d1, \u96c5\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/1b2d3e00a7df03689797ebd4af8c5827ba5af936849a71050ec331f4cf902c5d?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/1b2d3e00a7df03689797ebd4af8c5827ba5af936849a71050ec331f4cf902c5d?s=96&d=mm&r=g\",\"caption\":\"\u79d1, \u96c5\"},\"url\":\"https:\/\/www.silicloud.com\/zh\/blog\/author\/keya\/\"},{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/%e5%9c%a8ubuntu%e4%b8%8a%e5%ae%89%e8%a3%85postgres%e3%80%82-6\/#local-main-organization-logo\",\"url\":\"\",\"contentUrl\":\"\",\"caption\":\"Blog - Silicon Cloud\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"\u5728Ubuntu\u4e0a\u5b89\u88c5Postgres - Blog - Silicon Cloud","description":"\u5173\u4e8e\u5728Ubuntu\u4e0a\u5b89\u88c5Postgres\u7684\u6280\u672f\u6587\u7ae0","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.silicloud.com\/zh\/blog\/\u5728ubuntu\u4e0a\u5b89\u88c5postgres\u3002-6\/","og_locale":"zh_CN","og_type":"article","og_title":"\u5728Ubuntu\u4e0a\u5b89\u88c5Postgres","og_description":"\u5173\u4e8e\u5728Ubuntu\u4e0a\u5b89\u88c5Postgres\u7684\u6280\u672f\u6587\u7ae0","og_url":"https:\/\/www.silicloud.com\/zh\/blog\/\u5728ubuntu\u4e0a\u5b89\u88c5postgres\u3002-6\/","og_site_name":"Blog - Silicon Cloud","article_published_time":"2022-12-15T06:11:41+00:00","article_modified_time":"2025-08-11T08:03:00+00:00","author":"\u79d1, \u96c5","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"\u79d1, \u96c5","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"1 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.silicloud.com\/zh\/blog\/%e5%9c%a8ubuntu%e4%b8%8a%e5%ae%89%e8%a3%85postgres%e3%80%82-6\/","url":"https:\/\/www.silicloud.com\/zh\/blog\/%e5%9c%a8ubuntu%e4%b8%8a%e5%ae%89%e8%a3%85postgres%e3%80%82-6\/","name":"\u5728Ubuntu\u4e0a\u5b89\u88c5Postgres - Blog - Silicon Cloud","isPartOf":{"@id":"https:\/\/www.silicloud.com\/zh\/blog\/#website"},"datePublished":"2022-12-15T06:11:41+00:00","dateModified":"2025-08-11T08:03:00+00:00","author":{"@id":"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/41e222757cdd2a3365361328bd79970a"},"description":"\u5173\u4e8e\u5728Ubuntu\u4e0a\u5b89\u88c5Postgres\u7684\u6280\u672f\u6587\u7ae0","breadcrumb":{"@id":"https:\/\/www.silicloud.com\/zh\/blog\/%e5%9c%a8ubuntu%e4%b8%8a%e5%ae%89%e8%a3%85postgres%e3%80%82-6\/#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.silicloud.com\/zh\/blog\/%e5%9c%a8ubuntu%e4%b8%8a%e5%ae%89%e8%a3%85postgres%e3%80%82-6\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.silicloud.com\/zh\/blog\/%e5%9c%a8ubuntu%e4%b8%8a%e5%ae%89%e8%a3%85postgres%e3%80%82-6\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.silicloud.com\/zh\/blog\/"},{"@type":"ListItem","position":2,"name":"\u5728Ubuntu\u4e0a\u5b89\u88c5Postgres"}]},{"@type":"WebSite","@id":"https:\/\/www.silicloud.com\/zh\/blog\/#website","url":"https:\/\/www.silicloud.com\/zh\/blog\/","name":"Blog - Silicon Cloud","description":"","inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/41e222757cdd2a3365361328bd79970a","name":"\u79d1, \u96c5","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/1b2d3e00a7df03689797ebd4af8c5827ba5af936849a71050ec331f4cf902c5d?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/1b2d3e00a7df03689797ebd4af8c5827ba5af936849a71050ec331f4cf902c5d?s=96&d=mm&r=g","caption":"\u79d1, \u96c5"},"url":"https:\/\/www.silicloud.com\/zh\/blog\/author\/keya\/"},{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.silicloud.com\/zh\/blog\/%e5%9c%a8ubuntu%e4%b8%8a%e5%ae%89%e8%a3%85postgres%e3%80%82-6\/#local-main-organization-logo","url":"","contentUrl":"","caption":"Blog - Silicon Cloud"}]}},"_links":{"self":[{"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts\/25754","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/comments?post=25754"}],"version-history":[{"count":2,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts\/25754\/revisions"}],"predecessor-version":[{"id":94106,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts\/25754\/revisions\/94106"}],"wp:attachment":[{"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/media?parent=25754"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/categories?post=25754"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/tags?post=25754"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}