{"id":47038,"date":"2025-07-30T05:42:06","date_gmt":"2025-07-29T21:42:06","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/47038.html"},"modified":"2025-07-30T05:42:06","modified_gmt":"2025-07-29T21:42:06","slug":"postgresql%e5%a6%82%e4%bd%95%e8%bf%9b%e8%a1%8c%e8%b7%a8%e6%9c%8d%e5%8a%a1%e5%99%a8%e8%bf%81%e7%a7%bb%e6%95%b0%e6%8d%ae","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/47038.html","title":{"rendered":"PostgreSQL\u5982\u4f55\u8fdb\u884c\u8de8\u670d\u52a1\u5668\u8fc1\u79fb\u6570\u636e"},"content":{"rendered":"<\/p>\n<h4>\u6587\u7ae0\u76ee\u5f55<\/h4>\n<ul>\n<li>\n<ul>\n<li>1\u3001\u65b9\u6848<\/li>\n<li>2\u3001\u51c6\u5907\u5de5\u4f5c<\/li>\n<li>3\u3001\u64cd\u4f5c\u6d41\u7a0b<\/li>\n<li>\n<ul>\n<li>3.1 \u5bfc\u51fa\u539f\u59cb\u6570\u636e\u5e93\u6570\u636e<\/li>\n<li>3.2 \u4f20\u8f93\u6570\u636e\u6587\u4ef6<\/li>\n<li>3.3 \u76ee\u6807\u6570\u636e\u5e93\u5bfc\u5165\u6570\u636e<\/li>\n<li>\n<ul>\n<li>3.3.1 \u5bfc\u5165\u524d\u76ee\u6807\u6570\u636e\u5e93\u51c6\u5907<\/li>\n<li>3.3.2 \u6570\u636e\u5bfc\u5165<\/li>\n<\/ul>\n<\/li>\n<li>3.4 \u6570\u636e\u9a8c\u8bc1<\/li>\n<li>3.5 \u66f4\u65b0\u6570\u636e\u5e93\u7edf\u8ba1\u4fe1\u606f<\/li>\n<\/ul>\n<\/li>\n<li>4\u3001 \u5e94\u7528\u670d\u52a1\u6570\u636e\u66f4\u65b0<\/li>\n<li>\n<ul>\n<li>4.1 \u91cd\u5efaElasticSearch\u7d22\u5f15<\/li>\n<li>4.2 \u5e94\u7528\u6570\u636e\u68c0\u67e5<\/li>\n<\/ul>\n<\/li>\n<li>5\u3001\u9644\u5f55&#xff1a;pg_restore\u53c2\u6570\u8bf4\u660e<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<h3>1\u3001\u65b9\u6848<\/h3>\n<p>\u5728\u9488\u5bf9PostgreSQL\u7684\u6570\u636e\u8fc1\u79fb\u8fd9\u4e00\u5757\u529f\u80fd&#xff0c;\u5b98\u65b9\u6709\u76f8\u5e94\u7684\u5de5\u5177\u652f\u6301&#xff1a;pg_dump\u548cpg_restore&#xff0c;\u901a\u8fc7\u8fd9\u4e24\u4e2a\u5de5\u5177&#xff0c;\u53ef\u4ee5\u5f88\u597d\u7684\u5bf9\u6570\u636e\u5e93\u4e2d\u7684\u6570\u636e\u8fdb\u884c\u5907\u4efd\u548c\u6062\u590d\u3002\u90a3\u65e2\u7136\u652f\u6301\u901a\u8fc7\u5305\u6765\u5907\u4efd\u548c\u6062\u590d&#xff0c;\u90a3\u5728\u8de8\u670d\u52a1\u5668\u6570\u636e\u8fc1\u79fb&#xff0c;\u533a\u522b\u4e5f\u4ec5\u4ec5\u5728\u4e8ePostgreSQL\u670d\u52a1\u5668\u5730\u5740\u5b58\u5728\u5dee\u5f02&#xff0c;\u9700\u8981\u589e\u52a0\u6b65\u9aa4\u6765\u5728\u4e24\u53f0\u670d\u52a1\u5668\u4e4b\u95f4\u8fdb\u884c\u5907\u4efd\u6570\u636e\u5305\u7684\u4f20\u8f93\u5373\u53ef&#xff0c;\u57fa\u4e8e\u6b64&#xff0c;\u4e0b\u9762\u6765\u8bf4\u660e\u5982\u4f55\u6765\u64cd\u4f5c\u8fd9\u4e00\u7cfb\u5217\u8fc7\u7a0b\u3002<\/p>\n<h3>2\u3001\u51c6\u5907\u5de5\u4f5c<\/h3>\n<p>\u68b3\u7406\u672c\u5730\u73af\u5883\u4ee5\u53ca\u76ee\u6807\u73af\u5883\u76f8\u5e94\u53c2\u6570\u8868\u5982\u4e0b&#xff1a;<\/p>\n<table>\n<tr>\u914d\u7f6e\u9879\u6e90\u6570\u636e\u5e93&#xff08;\u672c\u5730&#xff09;\u76ee\u6807\u6570\u636e\u5e93&#xff08;\u8fdc\u7a0b&#xff09;<\/tr>\n<tbody>\n<tr>\n<td>\u670d\u52a1\u5668IP<\/td>\n<td>localhost(\u6216127.0.0.1)<\/td>\n<td>10.17.100.245<\/td>\n<\/tr>\n<tr>\n<td>\u6570\u636e\u5e93\u540d\u79f0<\/td>\n<td>sonarqube_db<\/td>\n<td>sonarqube_db&#xff08;\u53ef\u540c\u540d\u6216\u4e0d\u540c\u540d&#xff09;<\/td>\n<\/tr>\n<tr>\n<td>Postgresql\u8fde\u63a5\u7528\u6237<\/td>\n<td>sonar<\/td>\n<td>sonar<\/td>\n<\/tr>\n<tr>\n<td>Postgresql\u7aef\u53e3<\/td>\n<td>5432&#xff08;\u9ed8\u8ba4\u7aef\u53e3&#xff09;<\/td>\n<td>5432&#xff08;\u9ed8\u8ba4\u7aef\u53e3&#xff09;<\/td>\n<\/tr>\n<tr>\n<td>\u8fdc\u7a0b\u670d\u52a1\u5668\u7cfb\u7edf\u7528\u6237<\/td>\n<td>\u672c\u5730\u7528\u6237<\/td>\n<td>sonar&#xff08;\u7528\u4e8eSSH\/SCP\u4f20\u8f93&#xff09;<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u4e0a\u5c42\u670d\u52a1\u5e94\u7528&#xff1a;Sonarqube<\/p>\n<p>\u64cd\u4f5c\u6d41\u7a0b\u4e0e\u5b9e\u9645\u7684\u5e94\u7528\u670d\u52a1\u7406\u8bba\u4e0a\u65e0\u5173&#xff0c;\u8fd9\u91cc\u8bf4\u660e\u4e0a\u5c42\u5e94\u7528\u4ec5\u65b9\u4fbf\u540e\u7eed\u9a8c\u8bc1\u5b9e\u9645\u6570\u636e\u6062\u590d\u540e\u7684\u6548\u679c\u7528\u3002<\/p>\n<h3>3\u3001\u64cd\u4f5c\u6d41\u7a0b<\/h3>\n<h4>3.1 \u5bfc\u51fa\u539f\u59cb\u6570\u636e\u5e93\u6570\u636e<\/h4>\n<p>\u767b\u5f55\u539f\u59cb\u6570\u636e\u5e93\u6240\u5728\u7684Linux\u670d\u52a1\u5668&#xff0c;\u4ee5\u6570\u636e\u5e93\u7ba1\u7406\u5458\u8eab\u4efd\u767b\u5f55\u5230PostgreSQL&#xff1a;<\/p>\n<p><span class=\"token function\">sudo<\/span> -u postgres psql<\/p>\n<p>\u4f7f\u7528pg_dump\u547d\u4ee4\u5bfc\u51fa\u6570\u636e\u5e93\u4e2d\u7684\u6570\u636e:<\/p>\n<p><span class=\"token comment\"># \u4ece\u672c\u5730localhost 5432\u7aef\u53e3\u4ee5sonar\u8eab\u4efd\u767b\u5f55postgresql\u5c06sonarqube_db\u6570\u636e\u5e93\u5bfc\u51fa\u5230\u6587\u4ef6source_db_dump.custom<\/span><br \/>\npg_dump -h localhost -p <span class=\"token number\">5432<\/span> -U sonar -F c -v -f source_db_dump.custom sonarqube_db<\/p>\n<p>\u6267\u884c\u540e&#xff0c;\u4f1a\u8981\u6c42\u8f93\u5165sonar\u8d26\u6237\u7684\u53e3\u4ee4\u5bc6\u7801&#xff0c;\u8f93\u5165\u5bc6\u7801\u540e\u5f00\u59cb\u6b63\u5e38\u5bfc\u51fa\u6570\u636e&#xff1a;<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/07\/20250729214157-6889402542ce2.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<p>\u5bfc\u51fa\u5b8c\u6210\u540e&#xff0c;\u6570\u636e\u6587\u4ef6source_db_dump.custom\u5728\u5f53\u524d\u547d\u4ee4\u6267\u884c\u7684\u76ee\u5f55\u4e0b\u751f\u6210&#xff1a;<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/07\/20250729214157-68894025dea98.png\" alt=\"image-20250427141510791\" \/><\/p>\n<h4>3.2 \u4f20\u8f93\u6570\u636e\u6587\u4ef6<\/h4>\n<p>\u5728\u5b8c\u6210\u539f\u59cb\u6570\u636e\u5e93\u7684\u6570\u636e\u5bfc\u51fa\u4e4b\u540e&#xff0c;\u4f7f\u7528scp\u5de5\u5177\u5c06\u5176\u8fdc\u7a0b\u4f20\u8f93\u5230\u9700\u8981\u6062\u590d\u6570\u636e\u7684\u76ee\u6807\u670d\u52a1\u5668\u4e0a&#xff1a;<\/p>\n<p><span class=\"token comment\"># \u5c06\u4ee5sonar\u7528\u6237\u8eab\u4efd\u767b\u5f55\u523010.17.100.245\u670d\u52a1\u5668\u5e76\u4f20\u8f93source_db_dump.custom\u5230\/home\/sonar\u8def\u5f84<\/span><br \/>\n<span class=\"token function\">scp<\/span> source_db_dump.custom sonar&#064;10.17.100.245:\/home\/sonar\/<\/p>\n<p>\u8f93\u5165\u76ee\u6807\u670d\u52a1\u5668\u7684\u8fde\u63a5\u8d26\u6237\u5bc6\u7801\u540e\u5f00\u59cb\u4f20\u8f93&#xff1a;<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/07\/20250729214157-68894025e9262.png\" alt=\"image-20250427142251778\" \/><\/p>\n<p>\u4f20\u8f93\u5b8c\u6210\u540e&#xff0c;\u5f00\u59cb\u51c6\u5907\u4e0b\u4e00\u6b65\u5bfc\u5165\u6570\u636e\u3002<\/p>\n<h4>3.3 \u76ee\u6807\u6570\u636e\u5e93\u5bfc\u5165\u6570\u636e<\/h4>\n<h5>3.3.1 \u5bfc\u5165\u524d\u76ee\u6807\u6570\u636e\u5e93\u51c6\u5907<\/h5>\n<p>\u5728\u5f00\u59cb\u5bfc\u5165\u6570\u636e\u524d&#xff0c;\u9700\u63d0\u524d\u5bf9\u76ee\u6807\u670d\u52a1\u5668\u4e2d\u7684\u6570\u636e\u5e93\u505a\u4e00\u4e9b\u914d\u7f6e&#xff1a;<\/p>\n<p>1&#xff09;\u521b\u5efa\u76ee\u6807\u6570\u636e\u5e93<\/p>\n<ul>\n<li>\u767b\u5f55\u8fdc\u7a0b\u670d\u52a1\u5668&#xff0c;\u8fde\u63a5\u5230\u8fdc\u7a0b PostgreSQL \u6570\u636e\u5e93&#xff1a;<\/li>\n<\/ul>\n<p><span class=\"token comment\"># \u53ef\u80fd\u9700\u8981\u8f93\u5165 postgres \u7528\u6237\u7684\u5bc6\u7801<\/span><br \/>\n<span class=\"token function\">sudo<\/span> -u postgres psql<\/p>\n<ul>\n<li>\u521b\u5efa\u76ee\u6807\u6570\u636e\u5e93&#xff08;\u5df2\u6709\u5219\u5ffd\u7565\u6b64\u6b65\u9aa4&#xff09;<\/li>\n<\/ul>\n<p><span class=\"token comment\"># \u521b\u5efasonar\u8d26\u6237\u4e0b\u7684sonarqube_db\u6570\u636e\u5e93<\/span><br \/>\n<span class=\"token keyword\">CREATE<\/span> <span class=\"token keyword\">DATABASE<\/span> sonarqube_db OWNER sonar<span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token comment\"># \u68c0\u67e5\u662f\u5426\u521b\u5efa\u6210\u529f<\/span><br \/>\n\\\\l<br \/>\n<span class=\"token comment\"># \u5207\u6362\u5230sonarqube_db\u6570\u636e\u5e93<\/span><br \/>\n\\\\c sonarqube_db<br \/>\n<span class=\"token comment\"># \u5b8c\u6210\u521b\u5efa\u540e&#xff0c;\u9000\u51fa\u6570\u636e\u5e93\u5230\u7ec8\u7aef<\/span><br \/>\n\\\\q<\/p>\n<p>2&#xff09;\u6269\u5c55\u68c0\u67e5&#xff08;\u53ef\u9009&#xff09;<\/p>\n<p>\u5f53\u6e90\u6570\u636e\u5e93\u4f7f\u7528\u4e86\u6269\u5c55\u65f6&#xff0c;\u5fc5\u987b\u5728\u5bfc\u5165\u6570\u636e\u524d\u63d0\u524d\u5b89\u88c5\u5b8c\u6210\u6240\u6709\u7684\u63d2\u4ef6&#xff0c;\u5426\u5219\u5bfc\u5165\u65f6\u4f1a\u51fa\u73b0\u5f02\u5e38&#xff1a;<\/p>\n<ul>\n<li>\u68c0\u67e5\u6570\u636e\u5e93\u4f7f\u7528\u7684\u6269\u5c55<\/li>\n<\/ul>\n<p>sudo -u postgres psql\u767b\u5f55\u5230\u6e90PostgreSQL\u6570\u636e\u5e93&#xff0c;\u6267\u884c\u4e0b\u5217\u8bed\u53e5\u68c0\u67e5&#xff1a;<\/p>\n<p><span class=\"token comment\"># \u68c0\u67e5\u6570\u636e\u5e93\u4f7f\u7528\u7684\u63d2\u4ef6<\/span><br \/>\n\\\\dx<\/p>\n<ul>\n<li>\u5b89\u88c5\u5fc5\u8981\u63d2\u4ef6<\/li>\n<\/ul>\n<p>\u5f53\u68c0\u67e5\u51fa\u6709\u63d2\u4ef6\u5728\u4f7f\u7528\u65f6&#xff0c;\u9700\u9488\u5bf9\u6bcf\u4e00\u4e2a\u63d2\u4ef6\u8fdb\u884c\u5b89\u88c5&#xff1a;<\/p>\n<p><span class=\"token comment\">&#8212; \u793a\u4f8b&#xff1a;\u5b89\u88c5postgis\u63d2\u4ef6<\/span><br \/>\n<span class=\"token keyword\">CREATE<\/span> EXTENSION <span class=\"token keyword\">IF<\/span> <span class=\"token operator\">NOT<\/span> <span class=\"token keyword\">EXISTS<\/span> <span class=\"token string\">&#034;postgis&#034;<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>\u6bcf\u4e2a\u6269\u5c55\u4f7f\u7528CREATE EXTENSION\u8fdb\u884c\u5b89\u88c5\u3002<\/p>\n<h5>3.3.2 \u6570\u636e\u5bfc\u5165<\/h5>\n<p>\u5b8c\u6210\u5bfc\u5165\u524d\u7684\u51c6\u5907\u64cd\u4f5c\u540e&#xff0c;\u5728\u76ee\u6807\u670d\u52a1\u5668\u7ec8\u7aef\u5f00\u59cb\u5bfc\u5165\u6570\u636e&#xff1a;<\/p>\n<ul>\n<li>\u6570\u636e\u6587\u4ef6\u8def\u5f84\u5728&#xff1a;\/home\/sonar<\/li>\n<li>\u4f7f\u7528pg_restore\u5bfc\u5165\u6570\u636e&#xff1a;<\/li>\n<\/ul>\n<p><span class=\"token comment\"># \u76ee\u6807\u670d\u52a1\u5668\u505c\u6b62sonar\u670d\u52a1&#xff1a;\u505c\u6b62\u4e0a\u5c42\u5e94\u7528\u670d\u52a1<\/span><br \/>\n\/home\/sonar\/etc\/sonarqube\/sonarqube-10.4.0.87286\/bin\/linux-x86-64\/sonar.sh stop<br \/>\n<span class=\"token comment\"># \u79fb\u52a8\u5230\u6570\u636e\u6587\u4ef6\u76ee\u5f55<\/span><br \/>\n<span class=\"token builtin class-name\">cd<\/span> \/home\/sonar<br \/>\n<span class=\"token comment\"># \u7ec8\u7aef\u6267\u884c\u5c06source_db_dump.custom\u6570\u636e\u6587\u4ef6\u5bfc\u5165\u5230\u6570\u636e\u5e93sonarqube_db<\/span><br \/>\npg_restore -h localhost -p <span class=\"token number\">5432<\/span> -U sonar -v -d sonarqube_db &#8211;clean source_db_dump.custom<\/p>\n<p>\u8fd9\u91cc\u6211\u9009\u62e9\u4f7f\u7528&#8211;clean\u53c2\u6570\u4ee5\u8986\u76d6\u7684\u5f62\u5f0f\u66ff\u4ee3\u539f\u6709\u7684\u6240\u6709\u540c\u540d\u6570\u636e&#xff0c;\u65e0\u9700\u8986\u76d6\u53ef\u4e0d\u52a0\u6b64\u53c2\u6570&#xff0c;\u6839\u636e\u9700\u6c42\u4f7f\u7528&#xff1a;<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/07\/20250729214158-6889402638479.png\" alt=\"image-20250427172936647\" \/><\/p>\n<p>\u6ce8\u610f&#xff1a; \u8986\u76d6\u73b0\u6709\u7684\u6570\u636e\u540e&#xff0c;\u76ee\u6807\u670d\u52a1\u5668\u4e2d\u5df2\u6709\u7684\u6570\u636e\u4f1a\u88ab\u6e05\u6389&#xff0c;\u5e94\u7528\u670d\u52a1\u4e2d\u7684\u8d26\u6237\u5185\u5bb9\u4e5f\u4f1a\u66ff\u6362\u4e3a\u6e90\u6570\u636e\u5e93\u4e2d\u7684\u8d26\u6237&#xff0c;\u5982\u679c\u8d26\u6237\u540c\u540d&#xff0c;\u540e\u7eed\u4f7f\u7528\u65f6\u6ce8\u610f\u5bc6\u7801\u4f1a\u66f4\u65b0\u3002<\/p>\n<h4>3.4 \u6570\u636e\u9a8c\u8bc1<\/h4>\n<p><span class=\"token comment\"># \u8fde\u63a5\u5230\u76ee\u6807\u6570\u636e\u5e93<\/span><br \/>\n<span class=\"token function\">sudo<\/span> -u postgres psql<br \/>\n<span class=\"token comment\"># \u5207\u6362\u81f3sonarqube_db\u6570\u636e\u5e93<\/span><br \/>\n<span class=\"token punctuation\">\\\\<\/span>c sonarqube_db<br \/>\n<span class=\"token comment\"># \u5217\u51fa\u6240\u6709\u6570\u636e\u5e93<\/span><br \/>\n<span class=\"token punctuation\">\\\\<\/span>l<\/p>\n<p>\u6240\u6709\u7684\u6570\u636e\u5e93\u7ed3\u679c\u5982\u4e0b&#xff1a;<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/07\/20250729214158-68894026ccd6d.png\" alt=\"image-20250707223336718\" \/><\/p>\n<p><span class=\"token comment\"># \u5217\u51fa\u6240\u6709\u8868&#xff0c;\u68c0\u67e5\u6570\u91cf\u662f\u5426\u4e0e\u6e90\u6570\u636e\u5e93\u5927\u81f4\u76f8\u540c\u3002q\u9000\u51fa<\/span><br \/>\n<span class=\"token punctuation\">\\\\<\/span>dt<\/p>\n<p>\u8bb0\u5f55\u6570\u68c0\u67e5\u7ed3\u679c\u5982\u4e0b&#xff0c;\u53ef\u4ee5\u770b\u5230\u6570\u636e\u8bb0\u5f55\u662f\u524d\u540e\u4e00\u81f4\u7684&#xff1a;<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/07\/20250729214159-68894027a3353.png\" alt=\"image-20250427150947568\" \/><\/p>\n<p><span class=\"token comment\"># \u68c0\u67e5\u6240\u6709\u5e8f\u5217\u662f\u5426\u5b58\u5728<\/span><br \/>\n<span class=\"token punctuation\">\\\\<\/span>ds<\/p>\n<p>\u9009\u53d6projects\u8868\u4f5c\u4e3a\u6570\u636e\u5bf9\u6bd4\u8868&#xff0c;\u68c0\u67e5\u8bb0\u5f55&#xff1a;<\/p>\n<p><span class=\"token keyword\">SELECT<\/span> <span class=\"token function\">COUNT<\/span><span class=\"token punctuation\">(<\/span><span class=\"token operator\">*<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token keyword\">FROM<\/span> projects<span class=\"token punctuation\">;<\/span><\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/07\/20250729214202-6889402a503f1.png\" alt=\"image-20250707224033068\" \/><\/p>\n<p>\u4e0a\u8ff0\u8bb0\u5f55\u53ef\u4ee5\u770b\u5230\u6570\u636e\u5df2\u7ecf\u540c\u6b65\u6b63\u5e38&#xff0c;\u6240\u6709\u7684\u9879\u76ee\u5747\u5df2\u5bfc\u5165\u3002\u4e5f\u53ef\u4ee5\u5bf9\u6570\u636e\u8fdb\u884c\u62bd\u67e5\u68c0\u67e5\u6570\u636e\u5185\u5bb9\u662f\u5426\u6709\u9519\u8bef&#xff1a;<\/p>\n<p><span class=\"token keyword\">SELECT<\/span> <span class=\"token operator\">*<\/span> <span class=\"token keyword\">FROM<\/span> projects <span class=\"token keyword\">LIMIT<\/span> <span class=\"token number\">10<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>Tips&#xff1a; \u5728\u5bfc\u5165\u6570\u636e\u65f6\u6ca1\u6709\u8981\u6c42\u6570\u636e\u5e93\u8981\u505c\u6b62\u670d\u52a1&#xff0c;\u4f46\u907f\u514d\u53ef\u80fd\u5728\u5bfc\u5165\u65f6\u6709\u5176\u4ed6\u7528\u6237\u6216\u5e94\u7528\u5b58\u5728\u6570\u636e\u66f4\u65b0\u800c\u5bfc\u81f4\u6570\u636e\u5f02\u5e38&#xff0c;\u6700\u597d\u8fd8\u662f\u5148\u505c\u6b62\u6570\u636e\u5e93\u670d\u52a1\u518d\u8fdb\u884c\u6570\u636e\u5bfc\u5165\u3002<\/p>\n<h4>3.5 \u66f4\u65b0\u6570\u636e\u5e93\u7edf\u8ba1\u4fe1\u606f<\/h4>\n<p>\u5f53\u6570\u636e\u5b58\u5728\u66f4\u65b0\u65f6&#xff0c;\u9700\u8981\u5bf9\u6570\u636e\u5e93\u7edf\u8ba1\u4fe1\u606f\u8fdb\u884c\u66f4\u65b0&#xff1a;<\/p>\n<p><span class=\"token comment\"># \u5207\u6362\u5230postgresql\u7ba1\u7406\u5458\u7528\u6237<\/span><br \/>\n<span class=\"token function\">sudo<\/span> -i -u postgres<br \/>\npsql -d sonarqube_db<br \/>\n<span class=\"token comment\"># \u66f4\u65b0\u7edf\u8ba1\u4fe1\u606f<\/span><br \/>\nANALYZE VERBOSE<span class=\"token punctuation\">;<\/span><\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/07\/20250729214202-6889402a92920.png\" alt=\"image-20250427163801111\" \/><\/p>\n<p>\u5f53\u51fa\u73b0\u4ee5\u4e0b\u62a5\u9519&#xff0c;\u4e3a\u975e\u7ba1\u7406\u5458\u8d26\u6237\u8fdb\u884c\u7684\u66f4\u65b0\u64cd\u4f5c\u5bfc\u81f4&#xff0c;\u5207\u6362\u7ba1\u7406\u5458\u8eab\u4efd\u91cd\u65b0\u64cd\u4f5c\u5373\u53ef&#xff1a;<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/07\/20250729214203-6889402b004d8.png\" alt=\"image-20250427164210978\" \/><\/p>\n<p>\u5982\u679c\u6570\u636e\u5e93\u5b58\u5728\u540d\u79f0\u53d8\u66f4&#xff0c;\u4e0a\u5c42\u4f7f\u7528\u6b64\u6570\u636e\u5e93\u7684\u5e94\u7528\u4e00\u5b9a\u8981\u66f4\u65b0\u6307\u5411\u65b0\u7684\u6570\u636e\u5e93\u3002\u81f3\u6b64&#xff0c;\u6240\u6709\u6570\u636e\u5b8c\u6210\u8fc1\u79fb\u3002<\/p>\n<h3>4\u3001 \u5e94\u7528\u670d\u52a1\u6570\u636e\u66f4\u65b0<\/h3>\n<h4>4.1 \u91cd\u5efaElasticSearch\u7d22\u5f15<\/h4>\n<p>\u7531\u4e8e\u6211\u8fd9\u8fb9\u4e0a\u5c42\u4f7f\u7528PostgreSQL\u6570\u636e\u7684\u5e94\u7528\u4e3aSonarqube&#xff0c;\u5176\u4e2d\u5305\u542bES\u670d\u52a1&#xff0c;\u5bf9\u4e8e\u6570\u636e\u5e93\u5b58\u5728\u66f4\u65b0\u65f6&#xff0c;\u4e3a\u4e86\u4fdd\u969c\u6570\u636e\u4f7f\u7528\u6b63\u5e38&#xff0c;\u9700\u8981\u5bf9ES\u8fdb\u884c\u7d22\u5f15\u91cd\u5efa&#xff0c;\u64cd\u4f5c\u6b65\u9aa4\u5982\u4e0b&#xff1a;<\/p>\n<ul>\n<li>\n<p>1\u3001\u505c\u6b62SonarQube\u670d\u52a1\u5668\/\u96c6\u7fa4<\/p>\n<\/li>\n<li>\n<p>2\u3001\u8fdb\u5165SonarQube\u7684\u5b89\u88c5\u76ee\u5f55\/etc\/sonarqube\/sonarqube-10.4.0.87286\/data<\/p>\n<\/li>\n<\/ul>\n<p>\/etc\/sonarqube\/sonarqube-10.4.0.87286\u4e3a\u672c\u5730Sonar\u5b89\u88c5\u8def\u5f84&#xff0c;\u6839\u636e\u5b9e\u9645\u8def\u5f84\u6267\u884c<\/p>\n<ul>\n<li>3\u3001\u5220\u9664\/etc\/sonarqube\/sonarqube-10.4.0.87286\/data\/data\/es8 \u76ee\u5f55\u4e0b\u7684\u6240\u6709\u5185\u5bb9 &#xff08;\u9700\u8981\u6ce8\u610f\u5728\u8f83\u65e7\u7684ES\u7248\u672c\u4e2d&#xff0c;\u6b64\u76ee\u5f55\u53ef\u80fd\u4e3a es6 \u6216 es7&#xff09;<\/li>\n<\/ul>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/07\/20250729214203-6889402b18950.png\" alt=\"image-20250427173435009\" \/><\/p>\n<ul>\n<li>4\u3001\u91cd\u65b0\u542f\u52a8SonarQube\u670d\u52a1\u5668\/\u96c6\u7fa4\u3002<\/li>\n<\/ul>\n<p>\u5177\u4f53\u539f\u56e0\u662f&#xff0c;es8\u76ee\u5f55\u5305\u542bElasticsearch\u7684\u7d22\u5f15&#xff0c;\u5f53\u6b64\u76ee\u5f55\u4e0d\u5b58\u5728\u65f6&#xff0c;\u8feb\u4f7fSonarQube\u8bc6\u522b\u5230Elasticsearch\u7d22\u5f15\u7684\u7f3a\u5931&#xff0c;\u5728\u670d\u52a1\u542f\u52a8\u65f6\u4f1a\u89e6\u53d1\u5b8c\u6574\u7684\u7d22\u5f15\u91cd\u5efa\u8fc7\u7a0b&#xff0c;\u4ece\u800c\u786e\u4fdd\u7d22\u5f15\u662f\u57fa\u4e8e\u65b0\u8fc1\u79fb\u7684\u6570\u636e\u5e93\u6784\u5efa\u7684\u3002<\/p>\n<h4>4.2 \u5e94\u7528\u6570\u636e\u68c0\u67e5<\/h4>\n<p>\u91cd\u65b0\u542f\u52a8\u670d\u52a1&#xff0c;\u68c0\u67e5\u6570\u636e\u662f\u5426\u6b63\u5e38&#xff1a;\u53ef\u4ee5\u770b\u5230\u6240\u6709\u7684\u9879\u76ee\u90fd\u5df2\u5b8c\u5168\u5bfc\u5165&#xff0c;\u90e8\u5206\u7ec6\u8282\u8bbf\u95ee&#xff0c;\u5982issue\u677f\u5757&#xff0c;\u9700\u8981\u5728\u7d22\u5f15\u91cd\u5efa\u5b8c\u6210\u540e\u624d\u80fd\u5b8c\u6574\u67e5\u770b\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/07\/20250729214203-6889402b2da1e.png\" alt=\"image-20250707231014112\" \/><\/p>\n<p>\u5b8c\u6210\u7d22\u5f15\u91cd\u5efa\u540e&#xff0c;\u6240\u6709\u9875\u9762\u90fd\u53ef\u6b63\u5e38\u8bbf\u95ee&#xff1a;<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/07\/20250729214203-6889402be9043.png\" alt=\"image-20250427174202706\" \/><\/p>\n<h3>5\u3001\u9644\u5f55&#xff1a;pg_restore\u53c2\u6570\u8bf4\u660e<\/h3>\n<p>pg_restore\u547d\u4ee4\u683c\u5f0f\u5982\u4e0bpg_restore [\u9009\u9879]&#8230; [\u6587\u4ef6\u540d]&#xff0c;\u5177\u4f53\u652f\u6301\u7684\u53c2\u6570\u5982\u4e0b&#xff0c;\u4f9b\u4f7f\u7528\u65f6\u53c2\u8003&#xff1a;<\/p>\n<p>\u4e00\u822c\u9009\u9879:<br \/>\n  -d, &#8211;dbname<span class=\"token operator\">&#061;<\/span>\u540d\u5b57        \u8fde\u63a5\u6570\u636e\u5e93\u540d\u5b57<br \/>\n  -f, &#8211;file<span class=\"token operator\">&#061;<\/span>\u6587\u4ef6\u540d        \u8f93\u51fa\u6587\u4ef6\u540d<br \/>\n  -F, &#8211;format<span class=\"token operator\">&#061;<\/span>c<span class=\"token operator\">|<\/span>d<span class=\"token operator\">|<\/span>t       \u5907\u4efd\u6587\u4ef6\u683c\u5f0f<span class=\"token punctuation\">(<\/span>\u5e94\u8be5\u81ea\u52a8\u8fdb\u884c<span class=\"token punctuation\">)<\/span><br \/>\n  -l, &#8211;list               \u6253\u5370\u5f52\u6863\u6587\u4ef6\u7684 TOC \u6982\u8ff0<br \/>\n  -v, &#8211;verbose            \u8be6\u7ec6\u6a21\u5f0f<br \/>\n  -V, &#8211;version            \u8f93\u51fa\u7248\u672c\u4fe1\u606f, \u7136\u540e\u9000\u51fa<br \/>\n  -?, &#8211;help               \u663e\u793a\u6b64\u5e2e\u52a9, \u7136\u540e\u9000\u51fa<\/p>\n<p>\u6062\u590d\u63a7\u5236\u9009\u9879:<br \/>\n  -a, &#8211;data-only              \u53ea\u6062\u590d\u6570\u636e, \u4e0d\u5305\u62ec\u6a21\u5f0f<br \/>\n  -c, &#8211;clean                  \u5728\u91cd\u65b0\u521b\u5efa\u4e4b\u524d&#xff0c;\u5148\u6e05\u9664&#xff08;\u5220\u9664&#xff09;\u6570\u636e\u5e93\u5bf9\u8c61<br \/>\n  -C, &#8211;create                 \u521b\u5efa\u76ee\u6807\u6570\u636e\u5e93<br \/>\n  -e, &#8211;exit-on-error          \u53d1\u751f\u9519\u8bef\u9000\u51fa, \u9ed8\u8ba4\u4e3a\u7ee7\u7eed<br \/>\n  -I, &#8211;index<span class=\"token operator\">&#061;<\/span>NAME             \u6062\u590d\u6307\u5b9a\u540d\u79f0\u7684\u7d22\u5f15<br \/>\n  -j, &#8211;jobs<span class=\"token operator\">&#061;<\/span>NUM               \u6267\u884c\u591a\u4e2a\u5e76\u884c\u4efb\u52a1\u8fdb\u884c\u6062\u590d\u5de5\u4f5c<br \/>\n  -L, &#8211;use-list<span class=\"token operator\">&#061;<\/span>FILENAME      \u4ece\u8fd9\u4e2a\u6587\u4ef6\u4e2d\u4f7f\u7528\u6307\u5b9a\u7684\u5185\u5bb9\u8868\u6392\u5e8f<br \/>\n                               \u8f93\u51fa<br \/>\n  -n, &#8211;schema<span class=\"token operator\">&#061;<\/span>NAME            \u5728\u8fd9\u4e2a\u6a21\u5f0f\u4e2d\u53ea\u6062\u590d\u5bf9\u8c61<br \/>\n  -N, &#8211;exclude-schema<span class=\"token operator\">&#061;<\/span>NAME    \u4e0d\u6062\u590d\u6b64\u6a21\u5f0f\u4e2d\u7684\u5bf9\u8c61<br \/>\n  -O, &#8211;no-owner               \u4e0d\u6062\u590d\u5bf9\u8c61\u6240\u5c5e\u8005<br \/>\n  -P, &#8211;function<span class=\"token operator\">&#061;<\/span>NAME<span class=\"token punctuation\">(<\/span>args<span class=\"token punctuation\">)<\/span>    \u6062\u590d\u6307\u5b9a\u540d\u5b57\u7684\u51fd\u6570<br \/>\n  -s, &#8211;schema-only            \u53ea\u6062\u590d\u6a21\u5f0f, \u4e0d\u5305\u62ec\u6570\u636e<br \/>\n  -S, &#8211;superuser<span class=\"token operator\">&#061;<\/span>NAME         \u4f7f\u7528\u6307\u5b9a\u7684\u8d85\u7ea7\u7528\u6237\u6765\u7981\u7528\u89e6\u53d1\u5668<br \/>\n  -t, &#8211;table<span class=\"token operator\">&#061;<\/span>NAME             \u6062\u590d\u547d\u540d\u5173\u7cfb&#xff08;\u8868\u3001\u89c6\u56fe\u7b49&#xff09;<br \/>\n  -T, &#8211;trigger<span class=\"token operator\">&#061;<\/span>NAME           \u6062\u590d\u6307\u5b9a\u540d\u5b57\u7684\u89e6\u53d1\u5668<br \/>\n  -x, &#8211;no-privileges          \u8df3\u8fc7\u5904\u7406\u6743\u9650\u7684\u6062\u590d <span class=\"token punctuation\">(<\/span>grant\/revoke<span class=\"token punctuation\">)<\/span><br \/>\n  -1, &#8211;single-transaction     \u4f5c\u4e3a\u5355\u4e2a\u4e8b\u52a1\u6062\u590d<br \/>\n  &#8211;disable-triggers           \u5728\u53ea\u6062\u590d\u6570\u636e\u7684\u8fc7\u7a0b\u4e2d\u7981\u7528\u89e6\u53d1\u5668<br \/>\n  &#8211;enable-row-security        \u542f\u7528\u884c\u5b89\u5168\u6027<br \/>\n  &#8211;if-exists                  \u5f53\u5220\u9664\u5bf9\u8c61\u65f6\u4f7f\u7528IF EXISTS<br \/>\n  &#8211;no-comments                \u4e0d\u6062\u590d\u6ce8\u91ca<br \/>\n  &#8211;no-data-for-failed-tables  \u5bf9\u90a3\u4e9b\u65e0\u6cd5\u521b\u5efa\u7684\u8868\u4e0d\u8fdb\u884c<br \/>\n                               \u6570\u636e\u6062\u590d<br \/>\n  &#8211;no-publications            \u4e0d\u6062\u590d\u53d1\u884c<br \/>\n  &#8211;no-security-labels         \u4e0d\u6062\u590d\u5b89\u5168\u6807\u7b7e\u4fe1\u606f<br \/>\n  &#8211;no-subscriptions           \u4e0d\u6062\u590d\u8ba2\u9605<br \/>\n  &#8211;no-tablespaces             \u4e0d\u6062\u590d\u8868\u7a7a\u95f4\u7684\u5206\u914d\u4fe1\u606f<br \/>\n  &#8211;section<span class=\"token operator\">&#061;<\/span>SECTION            \u6062\u590d\u547d\u540d\u8282 <span class=\"token punctuation\">(<\/span>\u6570\u636e\u524d\u3001\u6570\u636e\u53ca\u6570\u636e\u540e<span class=\"token punctuation\">)<\/span><br \/>\n  &#8211;strict-names               \u8981\u6c42\u6bcf\u4e2a\u8868\u548c<span class=\"token punctuation\">(<\/span>\u6216<span class=\"token punctuation\">)<\/span>schema\u5305\u62ec\u6a21\u5f0f\u4ee5\u5339\u914d\u81f3\u5c11\u4e00\u4e2a\u5b9e\u4f53<br \/>\n  &#8211;use-set-session-authorization<br \/>\n                               \u4f7f\u7528 <span class=\"token environment constant\">SESSION<\/span> AUTHORIZATION \u547d\u4ee4\u4ee3\u66ff<br \/>\n                               ALTER OWNER \u547d\u4ee4\u6765\u8bbe\u7f6e\u6240\u6709\u6743<\/p>\n<p>\u8054\u63a5\u9009\u9879:<br \/>\n  -h, &#8211;host<span class=\"token operator\">&#061;<\/span>\u4e3b\u673a\u540d        \u6570\u636e\u5e93\u670d\u52a1\u5668\u7684\u4e3b\u673a\u540d\u6216\u5957\u63a5\u5b57\u76ee\u5f55<br \/>\n  -p, &#8211;port<span class=\"token operator\">&#061;<\/span>\u7aef\u53e3\u53f7        \u6570\u636e\u5e93\u670d\u52a1\u5668\u7684\u7aef\u53e3\u53f7<br \/>\n  -U, &#8211;username<span class=\"token operator\">&#061;<\/span>\u540d\u5b57      \u4ee5\u6307\u5b9a\u7684\u6570\u636e\u5e93\u7528\u6237\u8054\u63a5<br \/>\n  -w, &#8211;no-password        \u6c38\u8fdc\u4e0d\u63d0\u793a\u8f93\u5165\u53e3\u4ee4<br \/>\n  -W, &#8211;password           \u5f3a\u5236\u53e3\u4ee4\u63d0\u793a <span class=\"token punctuation\">(<\/span>\u81ea\u52a8<span class=\"token punctuation\">)<\/span><br \/>\n  &#8211;role<span class=\"token operator\">&#061;<\/span>ROLENAME          \u5728\u6062\u590d\u524d\u6267\u884cSET ROLE\u64cd\u4f5c<\/p>\n<p>\u9009\u9879 -I, -n, -N, -P, -t, -T, \u4ee5\u53ca &#8211;section \u53ef\u4ee5\u7ec4\u5408\u4f7f\u7528\u548c\u6307\u5b9a<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb730\u6b21\uff0c\u70b9\u8d5e10\u6b21\uff0c\u6536\u85cf27\u6b21\u3002\u672c\u6587\u8be6\u7ec6\u4ecb\u7ecd\u4e86PostgreSQL\u6570\u636e\u5e93\u8de8\u670d\u52a1\u5668\u8fc1\u79fb\u7684\u64cd\u4f5c\u6d41\u7a0b\uff0c\u4e3b\u8981\u5305\u62ec\u4ee5\u4e0b\u6b65\u9aa4\uff1a \u4f7f\u7528pg_dump\u5de5\u5177\u4ece\u6e90\u670d\u52a1\u5668\u5bfc\u51fa\u6570\u636e\u5e93\u6570\u636e\u5305 \u901a\u8fc7SCP\u5c06\u6570\u636e\u6587\u4ef6\u4f20\u8f93\u5230\u76ee\u6807\u670d\u52a1\u5668 \u5728\u76ee\u6807\u670d\u52a1\u5668\u4e0a\u8fdb\u884c\u5bfc\u5165\u524d\u51c6\u5907\uff08\u521b\u5efa\u6570\u636e\u5e93\u3001\u5b89\u88c5\u6269\u5c55\u63d2\u4ef6\u7b49\uff09 \u4f7f\u7528pg_restore\u547d\u4ee4\u5bfc\u5165\u6570\u636e \u8fdb\u884c\u6570\u636e\u9a8c\u8bc1\u548c\u7edf\u8ba1\u4fe1\u606f\u66f4\u65b0 \u9488\u5bf9\u4e0a\u5c42\u5e94\u7528\uff08Sonarqube\uff09\u8fdb\u884cES\u7d22\u5f15\u91cd\u5efa\u548c\u670d\u52a1\u91cd\u542f \u6587\u4e2d\u63d0\u4f9b\u4e86\u5b8c\u6574\u7684\u64cd\u4f5c\u547d\u4ee4\u548c\u6ce8\u610f\u4e8b\u9879\uff0c\u5305\u62ec\u6570\u636e\u5e93\u914d\u7f6e\u53c2\u6570\u3001\u6269\u5c55\u63d2\u4ef6\u5904\u7406\u3001\u6570\u636e\u8986\u76d6\u9009\u9879\u3001\u505c\u6b62\u670d\u52a1\u5efa\u8bae\u7b49\u5173\u952e\u7ec6\u8282\uff0c\u5e76\u9644\u5e26\u5b9e\u9645\u6267\u884c\u622a\u56fe\u3002\u6700\u540e\u8fd8\u7279\u522b\u8bf4\u660e\u4e86Sona_postgres \u6570\u636e\u8fc1\u79fb<\/p>\n","protected":false},"author":2,"featured_media":47026,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[954,100,3326,43],"topic":[],"class_list":["post-47038","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-server","tag-postgresql","tag-100","tag-3326","tag-43"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>PostgreSQL\u5982\u4f55\u8fdb\u884c\u8de8\u670d\u52a1\u5668\u8fc1\u79fb\u6570\u636e - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\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.wsisp.com\/helps\/47038.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"PostgreSQL\u5982\u4f55\u8fdb\u884c\u8de8\u670d\u52a1\u5668\u8fc1\u79fb\u6570\u636e - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb730\u6b21\uff0c\u70b9\u8d5e10\u6b21\uff0c\u6536\u85cf27\u6b21\u3002\u672c\u6587\u8be6\u7ec6\u4ecb\u7ecd\u4e86PostgreSQL\u6570\u636e\u5e93\u8de8\u670d\u52a1\u5668\u8fc1\u79fb\u7684\u64cd\u4f5c\u6d41\u7a0b\uff0c\u4e3b\u8981\u5305\u62ec\u4ee5\u4e0b\u6b65\u9aa4\uff1a \u4f7f\u7528pg_dump\u5de5\u5177\u4ece\u6e90\u670d\u52a1\u5668\u5bfc\u51fa\u6570\u636e\u5e93\u6570\u636e\u5305 \u901a\u8fc7SCP\u5c06\u6570\u636e\u6587\u4ef6\u4f20\u8f93\u5230\u76ee\u6807\u670d\u52a1\u5668 \u5728\u76ee\u6807\u670d\u52a1\u5668\u4e0a\u8fdb\u884c\u5bfc\u5165\u524d\u51c6\u5907\uff08\u521b\u5efa\u6570\u636e\u5e93\u3001\u5b89\u88c5\u6269\u5c55\u63d2\u4ef6\u7b49\uff09 \u4f7f\u7528pg_restore\u547d\u4ee4\u5bfc\u5165\u6570\u636e \u8fdb\u884c\u6570\u636e\u9a8c\u8bc1\u548c\u7edf\u8ba1\u4fe1\u606f\u66f4\u65b0 \u9488\u5bf9\u4e0a\u5c42\u5e94\u7528\uff08Sonarqube\uff09\u8fdb\u884cES\u7d22\u5f15\u91cd\u5efa\u548c\u670d\u52a1\u91cd\u542f \u6587\u4e2d\u63d0\u4f9b\u4e86\u5b8c\u6574\u7684\u64cd\u4f5c\u547d\u4ee4\u548c\u6ce8\u610f\u4e8b\u9879\uff0c\u5305\u62ec\u6570\u636e\u5e93\u914d\u7f6e\u53c2\u6570\u3001\u6269\u5c55\u63d2\u4ef6\u5904\u7406\u3001\u6570\u636e\u8986\u76d6\u9009\u9879\u3001\u505c\u6b62\u670d\u52a1\u5efa\u8bae\u7b49\u5173\u952e\u7ec6\u8282\uff0c\u5e76\u9644\u5e26\u5b9e\u9645\u6267\u884c\u622a\u56fe\u3002\u6700\u540e\u8fd8\u7279\u522b\u8bf4\u660e\u4e86Sona_postgres \u6570\u636e\u8fc1\u79fb\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/47038.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2025-07-29T21:42:06+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/07\/20250729214157-6889402542ce2.png\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/47038.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/47038.html\",\"name\":\"PostgreSQL\u5982\u4f55\u8fdb\u884c\u8de8\u670d\u52a1\u5668\u8fc1\u79fb\u6570\u636e - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2025-07-29T21:42:06+00:00\",\"dateModified\":\"2025-07-29T21:42:06+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/47038.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/47038.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/47038.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"PostgreSQL\u5982\u4f55\u8fdb\u884c\u8de8\u670d\u52a1\u5668\u8fc1\u79fb\u6570\u636e\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"PostgreSQL\u5982\u4f55\u8fdb\u884c\u8de8\u670d\u52a1\u5668\u8fc1\u79fb\u6570\u636e - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","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.wsisp.com\/helps\/47038.html","og_locale":"zh_CN","og_type":"article","og_title":"PostgreSQL\u5982\u4f55\u8fdb\u884c\u8de8\u670d\u52a1\u5668\u8fc1\u79fb\u6570\u636e - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb730\u6b21\uff0c\u70b9\u8d5e10\u6b21\uff0c\u6536\u85cf27\u6b21\u3002\u672c\u6587\u8be6\u7ec6\u4ecb\u7ecd\u4e86PostgreSQL\u6570\u636e\u5e93\u8de8\u670d\u52a1\u5668\u8fc1\u79fb\u7684\u64cd\u4f5c\u6d41\u7a0b\uff0c\u4e3b\u8981\u5305\u62ec\u4ee5\u4e0b\u6b65\u9aa4\uff1a \u4f7f\u7528pg_dump\u5de5\u5177\u4ece\u6e90\u670d\u52a1\u5668\u5bfc\u51fa\u6570\u636e\u5e93\u6570\u636e\u5305 \u901a\u8fc7SCP\u5c06\u6570\u636e\u6587\u4ef6\u4f20\u8f93\u5230\u76ee\u6807\u670d\u52a1\u5668 \u5728\u76ee\u6807\u670d\u52a1\u5668\u4e0a\u8fdb\u884c\u5bfc\u5165\u524d\u51c6\u5907\uff08\u521b\u5efa\u6570\u636e\u5e93\u3001\u5b89\u88c5\u6269\u5c55\u63d2\u4ef6\u7b49\uff09 \u4f7f\u7528pg_restore\u547d\u4ee4\u5bfc\u5165\u6570\u636e \u8fdb\u884c\u6570\u636e\u9a8c\u8bc1\u548c\u7edf\u8ba1\u4fe1\u606f\u66f4\u65b0 \u9488\u5bf9\u4e0a\u5c42\u5e94\u7528\uff08Sonarqube\uff09\u8fdb\u884cES\u7d22\u5f15\u91cd\u5efa\u548c\u670d\u52a1\u91cd\u542f \u6587\u4e2d\u63d0\u4f9b\u4e86\u5b8c\u6574\u7684\u64cd\u4f5c\u547d\u4ee4\u548c\u6ce8\u610f\u4e8b\u9879\uff0c\u5305\u62ec\u6570\u636e\u5e93\u914d\u7f6e\u53c2\u6570\u3001\u6269\u5c55\u63d2\u4ef6\u5904\u7406\u3001\u6570\u636e\u8986\u76d6\u9009\u9879\u3001\u505c\u6b62\u670d\u52a1\u5efa\u8bae\u7b49\u5173\u952e\u7ec6\u8282\uff0c\u5e76\u9644\u5e26\u5b9e\u9645\u6267\u884c\u622a\u56fe\u3002\u6700\u540e\u8fd8\u7279\u522b\u8bf4\u660e\u4e86Sona_postgres \u6570\u636e\u8fc1\u79fb","og_url":"https:\/\/www.wsisp.com\/helps\/47038.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2025-07-29T21:42:06+00:00","og_image":[{"url":"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/07\/20250729214157-6889402542ce2.png"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"3 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/47038.html","url":"https:\/\/www.wsisp.com\/helps\/47038.html","name":"PostgreSQL\u5982\u4f55\u8fdb\u884c\u8de8\u670d\u52a1\u5668\u8fc1\u79fb\u6570\u636e - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2025-07-29T21:42:06+00:00","dateModified":"2025-07-29T21:42:06+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/47038.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/47038.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/47038.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"PostgreSQL\u5982\u4f55\u8fdb\u884c\u8de8\u670d\u52a1\u5668\u8fc1\u79fb\u6570\u636e"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/47038","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=47038"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/47038\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media\/47026"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=47038"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=47038"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=47038"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=47038"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}