{"id":949,"date":"2026-09-17T23:53:31","date_gmt":"2026-09-17T20:53:31","guid":{"rendered":"https:\/\/imaxis.ru\/?p=949"},"modified":"2026-09-18T00:10:13","modified_gmt":"2026-09-17T21:10:13","slug":"ustanovka-i-zapusk-postgresql-na-ubuntu","status":"publish","type":"post","link":"https:\/\/imaxis.ru\/?p=949","title":{"rendered":"\u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 \u0438 \u0437\u0430\u043f\u0443\u0441\u043a PostgreSQL \u043d\u0430 Ubuntu"},"content":{"rendered":"<h1>\u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 \u0438 \u0437\u0430\u043f\u0443\u0441\u043a PostgreSQL \u043d\u0430 Ubuntu<\/h1>\n<p>PostgreSQL \u2014 \u043e\u0431\u044a\u0435\u043a\u0442\u043d\u043e-\u0440\u0435\u043b\u044f\u0446\u0438\u043e\u043d\u043d\u0430\u044f \u0421\u0423\u0411\u0414. \u0412 \u044d\u0442\u043e\u0439 \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438 \u2014 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 \u0432\u0435\u0440\u0441\u0438\u0438 \u0438\u0437 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u044f \u041e\u0421 \u0438 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u044f PGDG \u0434\u043b\u044f \u0441\u0432\u0435\u0436\u0438\u0445 \u0432\u0435\u0440\u0441\u0438\u0439, \u0442\u0435\u0441\u0442\u043e\u0432\u043e\u0435 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435, \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u0435 \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u0438 \u0442\u0438\u043f\u043e\u0432\u044b\u0435 \u043e\u0448\u0438\u0431\u043a\u0438.<\/p>\n<p>\u0410\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0435 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u043c\u044b\u0435 \u0432\u0435\u0442\u043a\u0438 PostgreSQL \u2014 <strong>15\u201318<\/strong> (\u043d\u0430 \u0441\u0435\u043d\u0442\u044f\u0431\u0440\u044c 2026 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u044f\u044f \u2014 18.6).<\/p>\n<hr \/>\n<h2>\u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430<\/h2>\n<h3>\u0412\u0435\u0440\u0441\u0438\u044f \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u044f<\/h3>\n<pre><code class=\"language-bash\">apt search --names-only '^postgresql$'\napt install postgresql postgresql-contrib\n<\/code><\/pre>\n<p><strong>\u0418\u0437 \u043a\u043e\u0440\u043e\u0431\u043a\u0438 Ubuntu \u0441\u0442\u0430\u0432\u0438\u0442\u0441\u044f \u0441\u0432\u043e\u044f \u0432\u0435\u0440\u0441\u0438\u044f \u0421\u0423\u0411\u0414.<\/strong><\/p>\n<h3>\u0420\u0430\u0437\u043d\u044b\u0435 \u0432\u0435\u0440\u0441\u0438\u0438 (\u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439 PGDG)<\/h3>\n<pre><code class=\"language-bash\">echo &quot;deb http:\/\/apt.postgresql.org\/pub\/repos\/apt $(lsb_release -cs)-pgdg main&quot; &gt; \/etc\/apt\/sources.list.d\/postgresql.list\napt install gnupg2\ncurl -fsS https:\/\/www.postgresql.org\/media\/keys\/ACCC4CF8.asc | gpg2 --dearmor -o \/etc\/apt\/trusted.gpg.d\/postgresql.gpg\napt update\napt install postgresql-18 postgresql-contrib-18\n<\/code><\/pre>\n<p><strong>\u0412 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u2014 PostgreSQL 18. \u0417\u0430\u043c\u0435\u043d\u0438\u0442\u0435 \u043d\u043e\u043c\u0435\u0440 \u043d\u0430 \u043d\u0443\u0436\u043d\u0443\u044e \u0432\u0435\u0442\u043a\u0443 (15\u201318).<\/strong><\/p>\n<hr \/>\n<h2>\u0422\u0435\u0441\u0442\u043e\u0432\u043e\u0435 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h2>\n<pre><code class=\"language-bash\">su - postgres\npsql\n<\/code><\/pre>\n<pre><code class=\"language-sql\">=# dt *\n<\/code><\/pre>\n<pre><code>List of relations\n   Schema   |          Name           | Type  |  Owner\n------------+-------------------------+-------+----------\n pg_catalog | pg_aggregate            | table | postgres\n pg_catalog | pg_am                   | table | postgres\n ...\n<\/code><\/pre>\n<pre><code class=\"language-sql\">=# q\nexit\n<\/code><\/pre>\n<hr \/>\n<h2>\u041f\u043e\u043b\u0435\u0437\u043d\u044b\u0435 \u043a\u043e\u043c\u0430\u043d\u0434\u044b<\/h2>\n<pre><code class=\"language-sql\">=# CREATE USER dmosk WITH PASSWORD 'myPassword';\n=# CREATE DATABASE database1 WITH OWNER dmosk ENCODING 'UTF8' LC_COLLATE = 'en_US.UTF-8' LC_CTYPE = 'en_US.UTF-8' TEMPLATE = 'template0';\n<\/code><\/pre>\n<p><strong>\u0421\u043e\u0437\u0434\u0430\u043d \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c <code>dmosk<\/code> \u0438 \u0431\u0430\u0437\u0430 <code>database1<\/code> \u0441 \u0432\u043b\u0430\u0434\u0435\u043b\u044c\u0446\u0435\u043c <code>dmosk<\/code>.<\/strong><\/p>\n<hr \/>\n<h2>\u0412\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0435 \u043e\u0448\u0438\u0431\u043a\u0438<\/h2>\n<h3>1. ERROR: invalid locale name: &#171;ru_RU.UTF-8&#187;<\/h3>\n<p><strong>\u041f\u0440\u0438\u0447\u0438\u043d\u0430:<\/strong> \u0432 \u0441\u0438\u0441\u0442\u0435\u043c\u0435 \u043d\u0435 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u0430 \u043b\u043e\u043a\u0430\u043b\u044c, \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u0430\u044f \u0432 <code>LC_COLLATE<\/code>\/<code>LC_CTYPE<\/code> \u043f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u0431\u0430\u0437\u044b.<\/p>\n<p><strong>\u0420\u0435\u0448\u0435\u043d\u0438\u0435:<\/strong><\/p>\n<pre><code class=\"language-bash\">locale-gen ru_RU.UTF-8\nsystemctl restart postgresql\n<\/code><\/pre>\n<p><strong>\u0433\u0434\u0435 <code>ru_RU.UTF-8<\/code> \u2014 \u043d\u0443\u0436\u043d\u0430\u044f \u043b\u043e\u043a\u0430\u043b\u044c.<\/strong><\/p>\n<h3>2. New collation is incompatible<\/h3>\n<pre><code>ERROR:  new collation (en_US.UTF-8) is incompatible with the collation of the template database (C.UTF-8)\nHINT:  Use the same collation as in the template database, or use template0 as template.\n<\/code><\/pre>\n<p><strong>\u041f\u0440\u0438\u0447\u0438\u043d\u0430:<\/strong> \u043a\u043e\u0434\u0438\u0440\u043e\u0432\u043a\u0430 \u0448\u0430\u0431\u043b\u043e\u043d\u0430 \u043e\u0442\u043b\u0438\u0447\u0430\u0435\u0442\u0441\u044f \u043e\u0442 \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u0439.<\/p>\n<p><strong>\u0420\u0435\u0448\u0435\u043d\u0438\u0435:<\/strong> \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043a\u043e\u0434\u0438\u0440\u043e\u0432\u043a\u0443 \u0448\u0430\u0431\u043b\u043e\u043d\u0430 \u043b\u0438\u0431\u043e <code>template0<\/code>:<\/p>\n<pre><code class=\"language-sql\">&gt; CREATE DATABASE new_db ENCODING 'UTF8' LC_COLLATE = 'en_US.UTF-8' LC_CTYPE = 'en_US.UTF-8' TEMPLATE = template0;\n<\/code><\/pre>\n<hr \/>\n<h2>\u0422\u043e\u043d\u043a\u043e\u0441\u0442\u0438 \u0438 \u043f\u043e\u0434\u0432\u043e\u0434\u043d\u044b\u0435 \u043a\u0430\u043c\u043d\u0438<\/h2>\n<ul>\n<li><strong>\u0420\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439 PGDG<\/strong> \u2014 \u0434\u0430\u0451\u0442 \u0441\u0432\u0435\u0436\u0438\u0435 \u0432\u0435\u0440\u0441\u0438\u0438; \u043a\u043b\u044e\u0447 \u043a\u043b\u0430\u0434\u0451\u0442\u0441\u044f \u0432 <code>\/etc\/apt\/trusted.gpg.d\/<\/code>.<\/li>\n<li><strong>\u041b\u043e\u043a\u0430\u043b\u0438<\/strong> \u2014 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0439\u0442\u0435 \u043d\u0443\u0436\u043d\u044b\u0435 \u043b\u043e\u043a\u0430\u043b\u044c \u0434\u043e \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0431\u0430\u0437\u044b, \u0438\u043d\u0430\u0447\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0435 \u043e\u0448\u0438\u0431\u043a\u0443.<\/li>\n<li><strong><code>template0<\/code><\/strong> \u2014 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 \u043f\u0440\u0438 \u043d\u0435\u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0439 \u043a\u043e\u0434\u0438\u0440\u043e\u0432\u043a\u0435\/\u043b\u043e\u043a\u0430\u043b\u0438; <code>template1<\/code> \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e.<\/li>\n<li><strong>\u041a\u043b\u0430\u0441\u0442\u0435\u0440\u044b<\/strong> \u2014 Ubuntu \u0441\u0442\u0430\u0432\u0438\u0442 <code>postgresql-common<\/code> \u0441 <code>pg_ctlcluster<\/code>; \u0432\u0435\u0440\u0441\u0438\u0438 \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0447\u0435\u0440\u0435\u0437 <code>pg_lsclusters<\/code>.<\/li>\n<li><strong><code>pg_hba.conf<\/code><\/strong> \u2014 \u0434\u043b\u044f \u0443\u0434\u0430\u043b\u0451\u043d\u043d\u043e\u0433\u043e \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043f\u0440\u0430\u0432\u044c\u0442\u0435 \u044d\u0442\u043e\u0442 \u0444\u0430\u0439\u043b, \u0430 \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e <code>postgresql.conf<\/code>.<\/li>\n<li><strong>\u0411\u044d\u043a\u0430\u043f\u044b<\/strong> \u2014 <code>pg_dump<\/code>\/<code>pg_dumpall<\/code>; \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u043d\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0439\u0442\u0435 \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435.<\/li>\n<li><strong>\u0412\u0435\u0440\u0441\u0438\u0438<\/strong> \u2014 15\u201318 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u044e\u0442\u0441\u044f; \u0441\u0442\u0430\u0440\u044b\u0435 (12 \u0438 \u043d\u0438\u0436\u0435) EOL.<\/li>\n<li><strong>\u041f\u043e\u0440\u0442 5432<\/strong> \u2014 \u043e\u0442\u043a\u0440\u044b\u0432\u0430\u0439\u0442\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u0438 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u0432\u0430\u0439\u0442\u0435 \u0434\u043e\u0441\u0442\u0443\u043f.<\/li>\n<\/ul>\n<hr \/>\n<h2>\u0428\u043f\u0430\u0440\u0433\u0430\u043b\u043a\u0430<\/h2>\n<pre><code class=\"language-bash\"># \u0438\u0437 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u044f \u041e\u0421\napt install postgresql postgresql-contrib\n\n# \u0441\u0432\u0435\u0436\u0430\u044f \u0432\u0435\u0440\u0441\u0438\u044f (PGDG)\necho &quot;deb http:\/\/apt.postgresql.org\/pub\/repos\/apt $(lsb_release -cs)-pgdg main&quot; &gt; \/etc\/apt\/sources.list.d\/postgresql.list\ncurl -fsS https:\/\/www.postgresql.org\/media\/keys\/ACCC4CF8.asc | gpg2 --dearmor -o \/etc\/apt\/trusted.gpg.d\/postgresql.gpg\napt update &amp;&amp; apt install postgresql-18 postgresql-contrib-18\n\nsu - postgres &amp;&amp; psql\n=# CREATE USER dmosk WITH PASSWORD 'myPassword';\n=# CREATE DATABASE db1 WITH OWNER dmosk ENCODING 'UTF8' TEMPLATE = template0;\n<\/code><\/pre>\n<p><em>\u041f\u0440\u043e\u0432\u0435\u0440\u0435\u043d\u043e \u043d\u0430: Ubuntu 22.04\/24.04\/26.04 + PostgreSQL 15\u201318.<\/em><br \/>\n<em>\u0414\u0430\u0442\u0430: \u0421\u0435\u043d\u0442\u044f\u0431\u0440\u044c 2026.<\/em><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 \u0438 \u0437\u0430\u043f\u0443\u0441\u043a PostgreSQL \u043d\u0430 Ubuntu PostgreSQL \u2014 \u043e\u0431\u044a\u0435\u043a\u0442\u043d\u043e-\u0440\u0435\u043b\u044f\u0446\u0438\u043e\u043d\u043d\u0430\u044f \u0421\u0423\u0411\u0414.<\/p>\n","protected":false},"author":0,"featured_media":975,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"footnotes":""},"categories":[3],"tags":[],"class_list":["post-949","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-linux"],"aioseo_notices":[],"views":13,"_links":{"self":[{"href":"https:\/\/imaxis.ru\/index.php?rest_route=\/wp\/v2\/posts\/949","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/imaxis.ru\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/imaxis.ru\/index.php?rest_route=\/wp\/v2\/types\/post"}],"replies":[{"embeddable":true,"href":"https:\/\/imaxis.ru\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=949"}],"version-history":[{"count":2,"href":"https:\/\/imaxis.ru\/index.php?rest_route=\/wp\/v2\/posts\/949\/revisions"}],"predecessor-version":[{"id":952,"href":"https:\/\/imaxis.ru\/index.php?rest_route=\/wp\/v2\/posts\/949\/revisions\/952"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/imaxis.ru\/index.php?rest_route=\/wp\/v2\/media\/975"}],"wp:attachment":[{"href":"https:\/\/imaxis.ru\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=949"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/imaxis.ru\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=949"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/imaxis.ru\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=949"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}