{"id":179716,"date":"2024-11-09T04:12:21","date_gmt":"2024-11-08T20:12:21","guid":{"rendered":"https:\/\/server.hk\/cnblog\/179716\/"},"modified":"2024-11-09T04:12:22","modified_gmt":"2024-11-08T20:12:22","slug":"%e5%a6%82%e4%bd%95%e5%9c%a8-sql-%e4%b8%ad%e6%9f%a5%e7%9c%8b%e6%95%b8%e6%93%9a%e5%ba%ab%e5%af%86%e7%a2%bc-sql-%e6%95%b8%e6%93%9a%e5%ba%ab%e5%af%86%e7%a2%bc%e5%a6%82%e4%bd%95%e6%9f%a5%e7%9c%8b","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/179716\/","title":{"rendered":"\u5982\u4f55\u5728 SQL \u4e2d\u67e5\u770b\u6578\u64da\u5eab\u5bc6\u78bc (sql \u6578\u64da\u5eab\u5bc6\u78bc\u5982\u4f55\u67e5\u770b)"},"content":{"rendered":"<h1 id=\"%e5%a6%82%e4%bd%95%e5%9c%a8-sql-%e4%b8%ad%e6%9f%a5%e7%9c%8b%e6%95%b8%e6%93%9a%e5%ba%ab%e5%af%86%e7%a2%bc-gzJHXdpAXD\">\u5982\u4f55\u5728 SQL \u4e2d\u67e5\u770b\u6578\u64da\u5eab\u5bc6\u78bc<\/h1>\n<p>\u5728\u6578\u64da\u5eab\u7ba1\u7406\u4e2d\uff0c\u5bc6\u78bc\u7684\u5b89\u5168\u6027\u81f3\u95dc\u91cd\u8981\u3002\u7121\u8ad6\u662f MySQL\u3001PostgreSQL \u9084\u662f\u5176\u4ed6 SQL \u6578\u64da\u5eab\uff0c\u4e86\u89e3\u5982\u4f55\u7ba1\u7406\u548c\u67e5\u770b\u6578\u64da\u5eab\u5bc6\u78bc\u662f\u6bcf\u4f4d\u6578\u64da\u5eab\u7ba1\u7406\u54e1\u5fc5\u9808\u638c\u63e1\u7684\u6280\u80fd\u3002\u672c\u6587\u5c07\u63a2\u8a0e\u5728 SQL \u4e2d\u67e5\u770b\u6578\u64da\u5eab\u5bc6\u78bc\u7684\u76f8\u95dc\u77e5\u8b58\uff0c\u4e26\u63d0\u4f9b\u4e00\u4e9b\u5be6\u7528\u7684\u5efa\u8b70\u3002<\/p>\n<h2 id=\"%e6%95%b8%e6%93%9a%e5%ba%ab%e5%af%86%e7%a2%bc%e7%9a%84%e5%ad%98%e5%84%b2%e6%96%b9%e5%bc%8f-gzJHXdpAXD\">\u6578\u64da\u5eab\u5bc6\u78bc\u7684\u5b58\u5132\u65b9\u5f0f<\/h2>\n<p>\u9996\u5148\uff0c\u4e86\u89e3\u6578\u64da\u5eab\u5bc6\u78bc\u7684\u5b58\u5132\u65b9\u5f0f\u662f\u975e\u5e38\u91cd\u8981\u7684\u3002\u5927\u591a\u6578 SQL \u6578\u64da\u5eab\u4e0d\u6703\u4ee5\u660e\u6587\u5f62\u5f0f\u5b58\u5132\u5bc6\u78bc\uff0c\u800c\u662f\u4f7f\u7528\u96dc\u6e4a\u7b97\u6cd5\u9032\u884c\u52a0\u5bc6\u3002\u9019\u610f\u5473\u8457\uff0c\u5373\u4f7f\u4f60\u80fd\u5920\u8a2a\u554f\u6578\u64da\u5eab\u7684\u7528\u6236\u8868\uff0c\u4e5f\u7121\u6cd5\u76f4\u63a5\u67e5\u770b\u7528\u6236\u7684\u5bc6\u78bc\u3002<\/p>\n<ul>\n<li><strong>MySQL:<\/strong> MySQL \u4f7f\u7528 <code>mysql_native_password<\/code> \u6216 <code>caching_sha2_password<\/code> \u7b49\u63d2\u4ef6\u4f86\u52a0\u5bc6\u5bc6\u78bc\u3002<\/li>\n<li><strong>PostgreSQL:<\/strong> PostgreSQL \u901a\u5e38\u4f7f\u7528 <code>md5<\/code> \u6216 <code>scram-sha-256<\/code> \u9032\u884c\u5bc6\u78bc\u52a0\u5bc6\u3002<\/li>\n<\/ul>\n<h2 id=\"%e5%a6%82%e4%bd%95%e6%9f%a5%e7%9c%8b%e6%95%b8%e6%93%9a%e5%ba%ab%e7%94%a8%e6%88%b6%e4%bf%a1%e6%81%af-gzJHXdpAXD\">\u5982\u4f55\u67e5\u770b\u6578\u64da\u5eab\u7528\u6236\u4fe1\u606f<\/h2>\n<p>\u5118\u7ba1\u7121\u6cd5\u76f4\u63a5\u67e5\u770b\u5bc6\u78bc\uff0c\u4f46\u4f60\u53ef\u4ee5\u67e5\u770b\u7528\u6236\u7684\u76f8\u95dc\u4fe1\u606f\u3002\u4ee5\u4e0b\u662f\u4e00\u4e9b\u5e38\u898b\u7684 SQL \u67e5\u8a62\u793a\u4f8b\uff0c\u5e6b\u52a9\u4f60\u7372\u53d6\u7528\u6236\u4fe1\u606f\u3002<\/p>\n<h3 id=\"mysql-gzJHXdpAXD\">MySQL<\/h3>\n<pre><code>SELECT User, Host, authentication_string FROM mysql.user;<\/code><\/pre>\n<p>\u9019\u689d\u67e5\u8a62\u5c07\u8fd4\u56de\u6240\u6709\u7528\u6236\u7684\u540d\u7a31\u3001\u4e3b\u6a5f\u548c\u52a0\u5bc6\u5f8c\u7684\u5bc6\u78bc\u5b57\u7b26\u4e32\u3002\u8acb\u6ce8\u610f\uff0c<code>authentication_string<\/code> \u5217\u5305\u542b\u7684\u662f\u52a0\u5bc6\u5f8c\u7684\u5bc6\u78bc\uff0c\u800c\u4e0d\u662f\u660e\u6587\u5bc6\u78bc\u3002<\/p>\n<h3 id=\"postgresql-gzJHXdpAXD\">PostgreSQL<\/h3>\n<pre><code>SELECT usename, passwd FROM pg_shadow;<\/code><\/pre>\n<p>\u5728 PostgreSQL \u4e2d\uff0c\u9019\u689d\u67e5\u8a62\u5c07\u8fd4\u56de\u7528\u6236\u540d\u548c\u52a0\u5bc6\u5f8c\u7684\u5bc6\u78bc\u3002\u8207 MySQL \u4e00\u6a23\uff0c\u9019\u88e1\u7684\u5bc6\u78bc\u4e5f\u662f\u4ee5\u52a0\u5bc6\u5f62\u5f0f\u5b58\u5132\u7684\u3002<\/p>\n<h2 id=\"%e9%87%8d%e7%bd%ae%e6%95%b8%e6%93%9a%e5%ba%ab%e5%af%86%e7%a2%bc-gzJHXdpAXD\">\u91cd\u7f6e\u6578\u64da\u5eab\u5bc6\u78bc<\/h2>\n<p>\u5982\u679c\u4f60\u9700\u8981\u67e5\u770b\u6216\u66f4\u6539\u7528\u6236\u7684\u5bc6\u78bc\uff0c\u6700\u5b89\u5168\u7684\u65b9\u6cd5\u662f\u91cd\u7f6e\u5bc6\u78bc\u3002\u4ee5\u4e0b\u662f\u5982\u4f55\u5728 MySQL \u548c PostgreSQL \u4e2d\u91cd\u7f6e\u7528\u6236\u5bc6\u78bc\u7684\u793a\u4f8b\u3002<\/p>\n<h3 id=\"mysql-gzJHXdpAXD\">MySQL<\/h3>\n<pre><code>ALTER USER 'username'@'host' IDENTIFIED BY 'new_password';<\/code><\/pre>\n<p>\u9019\u689d\u547d\u4ee4\u5c07\u7528\u6236\u7684\u5bc6\u78bc\u66f4\u6539\u70ba\u65b0\u7684\u5bc6\u78bc\u3002<\/p>\n<h3 id=\"postgresql-gzJHXdpAXD\">PostgreSQL<\/h3>\n<pre><code>ALTER USER username WITH PASSWORD 'new_password';<\/code><\/pre>\n<p>\u9019\u689d\u547d\u4ee4\u540c\u6a23\u6703\u5c07\u6307\u5b9a\u7528\u6236\u7684\u5bc6\u78bc\u66f4\u6539\u70ba\u65b0\u7684\u5bc6\u78bc\u3002<\/p>\n<h2 id=\"%e6%95%b8%e6%93%9a%e5%ba%ab%e5%ae%89%e5%85%a8%e6%80%a7%e5%bb%ba%e8%ad%b0-gzJHXdpAXD\">\u6578\u64da\u5eab\u5b89\u5168\u6027\u5efa\u8b70<\/h2>\n<p>\u5728\u7ba1\u7406\u6578\u64da\u5eab\u5bc6\u78bc\u6642\uff0c\u9075\u5faa\u4e00\u4e9b\u6700\u4f73\u5be6\u8e10\u662f\u975e\u5e38\u91cd\u8981\u7684\uff1a<\/p>\n<ul>\n<li>\u5b9a\u671f\u66f4\u6539\u5bc6\u78bc\u4ee5\u63d0\u9ad8\u5b89\u5168\u6027\u3002<\/li>\n<li>\u4f7f\u7528\u5f37\u5bc6\u78bc\uff0c\u5305\u542b\u5b57\u6bcd\u3001\u6578\u5b57\u548c\u7279\u6b8a\u5b57\u7b26\u3002<\/li>\n<li>\u9650\u5236\u7528\u6236\u7684\u8a2a\u554f\u6b0a\u9650\uff0c\u50c5\u6388\u4e88\u5fc5\u8981\u7684\u6b0a\u9650\u3002<\/li>\n<li>\u5b9a\u671f\u5099\u4efd\u6578\u64da\u5eab\uff0c\u4ee5\u9632\u6578\u64da\u4e1f\u5931\u3002<\/li>\n<\/ul>\n<h2 id=\"%e7%b8%bd%e7%b5%90-gzJHXdpAXD\">\u7e3d\u7d50<\/h2>\n<p>\u5728 SQL \u6578\u64da\u5eab\u4e2d\uff0c\u67e5\u770b\u7528\u6236\u7684\u5bc6\u78bc\u4e26\u4e0d\u662f\u4e00\u500b\u76f4\u63a5\u7684\u904e\u7a0b\uff0c\u56e0\u70ba\u5bc6\u78bc\u901a\u5e38\u662f\u4ee5\u52a0\u5bc6\u5f62\u5f0f\u5b58\u5132\u7684\u3002\u901a\u904e\u67e5\u8a62\u7528\u6236\u4fe1\u606f\uff0c\u4f60\u53ef\u4ee5\u7372\u5f97\u6709\u95dc\u7528\u6236\u7684\u8a73\u7d30\u8cc7\u6599\uff0c\u4f46\u7121\u6cd5\u76f4\u63a5\u67e5\u770b\u660e\u6587\u5bc6\u78bc\u3002\u91cd\u7f6e\u5bc6\u78bc\u662f\u7ba1\u7406\u7528\u6236\u8a2a\u554f\u7684\u6700\u4f73\u65b9\u6cd5\uff0c\u4e26\u4e14\u9075\u5faa\u5b89\u5168\u6027\u6700\u4f73\u5be6\u8e10\u5c07\u6709\u52a9\u65bc\u4fdd\u8b77\u4f60\u7684\u6578\u64da\u5eab\u5b89\u5168\u3002\u5982\u679c\u4f60\u9700\u8981\u66f4\u591a\u6709\u95dc <a href=\"https:\/\/server.hk\">\u9999\u6e2fVPS<\/a> \u548c\u6578\u64da\u5eab\u7ba1\u7406\u7684\u8cc7\u8a0a\uff0c\u8acb\u8a2a\u554f\u6211\u5011\u7684\u7db2\u7ad9\u4ee5\u7372\u53d6\u66f4\u591a\u8cc7\u6e90\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4e86\u89e3\u5982\u4f55\u5728 SQL \u4e2d\u67e5\u770b\u6578\u64da\u5eab\u5bc6\u78bc\uff0c\u638c\u63e1\u5b89\u5168\u7ba1\u7406\u6280\u5de7\uff0c\u78ba\u4fdd\u6578\u64da\u5eab\u7684\u5b89\u5168\u6027\u8207\u7a69\u5b9a\u6027\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-179716","post","type-post","status-publish","format-standard","hentry","category-database"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/179716","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=179716"}],"version-history":[{"count":1,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/179716\/revisions"}],"predecessor-version":[{"id":179717,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/179716\/revisions\/179717"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=179716"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=179716"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=179716"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}