{"id":6288,"date":"2024-11-14T11:29:01","date_gmt":"2024-11-14T03:29:01","guid":{"rendered":"https:\/\/fwq.ai\/blog\/6288\/"},"modified":"2024-11-14T11:29:01","modified_gmt":"2024-11-14T03:29:01","slug":"%e5%88%9b%e5%bb%ba%e5%8f%aa%e8%83%bd%e8%ae%bf%e9%97%ae-cloudsql-%e4%b8%ad%e4%b8%80%e4%b8%aa%e6%9e%b6%e6%9e%84%e7%9a%84%e7%94%a8%e6%88%b7","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/6288\/","title":{"rendered":"\u521b\u5efa\u53ea\u80fd\u8bbf\u95ee CloudSQL \u4e2d\u4e00\u4e2a\u67b6\u6784\u7684\u7528\u6237"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/000\/887\/227\/172058040726104.jpg\" class=\"aligncenter\" title=\"\u521b\u5efa\u53ea\u80fd\u8bbf\u95ee CloudSQL \u4e2d\u4e00\u4e2a\u67b6\u6784\u7684\u7528\u6237\u63d2\u56fe\" alt=\"\u521b\u5efa\u53ea\u80fd\u8bbf\u95ee CloudSQL \u4e2d\u4e00\u4e2a\u67b6\u6784\u7684\u7528\u6237\u63d2\u56fe\" \/><\/p>\n<p><strong>TL;DR:<\/strong> \u5728 Google Cloud Console \u4e2d\u521b\u5efa\u7528\u6237\u540e\uff0c\u4e0d\u8981\u5fd8\u8bb0 REVOKE &#8216;cloudsqlsuperuser&#8217;@&#8217;%&#8217; FROM &#8216;your-user&#8217;@&#8217;%&#8217;;\u5982\u679c\u60a8\u53ea\u60f3\u8ba9\u8be5\u7528\u6237\u8bbf\u95ee\u7279\u5b9a\u6a21\u5f0f\u3002<\/p>\n<hr>\n<p>\u901a\u8fc7 Google Cloud Console \u521b\u5efa MySQL \u7528\u6237\u4f1a\u81ea\u52a8\u6dfb\u52a0 cloudsqlsuperuser \u89d2\u8272\uff0c\u8be5\u89d2\u8272\u5141\u8bb8\u7528\u6237\u8bbf\u95ee\u8be5 MySQL \u5b9e\u4f8b\u4e0a\u7684\u6240\u6709\u5185\u5bb9\uff1a<\/p>\n<pre>\u663e\u793a 'user-from-gcp-console'@'%' \u7684\u8865\u52a9\u91d1\uff1b\n\n+------------------------------------------------ ------------+\n|\u6388\u4e88 user-from-gcp-console@% |\n+------------------------------------------------ ------------+\n|\u5c06 *.* \u7684\u4f7f\u7528\u6743\u6388\u4e88 `user-from-gcp-console`@`%` |\n|\u5c06 `cloudsqlsuperuser`@`%` \u6388\u4e88 `user-from-gcp-console`@`%`|\n+------------------------------------------------ ------------+\n<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>Google \u5728\u5176\u77e5\u8bc6\u5e93\u7684\u5173\u4e8e MySQL \u7528\u6237\u6587\u7ae0\u4e2d\u63d0\u5230\u4e86\u8fd9\u4e00\u70b9\u3002<\/p>\n<p>\u8981\u521b\u5efa\u53ea\u80fd\u8bbf\u95ee\u4e00\u79cd\u67b6\u6784\u7684\u7528\u6237\uff0c\u60a8\u9700\u8981\u901a\u8fc7\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\u6765\u521b\u5efa\u6ca1\u6709\u63a7\u5236\u53f0\u7684\u7528\u6237\uff1a<\/p>\n<pre>\u521b\u5efa\u7528\u6237\u201c\u60a8\u7684\u7528\u6237\u201d@\u201c%\u201d\u5df2\u8bc6\u522b\n    \u4f7f\u7528\u201cmysql_native_password\u201d\n    BY '&lt;\u67d0\u4e9b\u5f3a\u5bc6\u7801&gt;';\n\n\u5c06 your-schema.* \u4e0a\u7684\u6240\u6709\u5185\u5bb9\u6388\u4e88 'your-user'@'%';\n<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u6216\u8005\u901a\u8fc7\u63a7\u5236\u53f0\u521b\u5efa\u7528\u6237\uff0c\u4f46\u4e0d\u8981\u5fd8\u8bb0\u5220\u9664 cloudsqlsuperuser \u89d2\u8272\uff1a<\/p>\n<pre>\/\/ \u901a\u8fc7 Google Cloud Console \u521b\u5efa\u7528\u6237\n\n\u4ece\u201c\u60a8\u7684\u7528\u6237\u201d@\u201c%\u201d\u4e2d\u64a4\u9500\u201ccloudsqlsuperuser\u201d@\u201c%\u201d\uff1b\n\u5c06 your-schema.* \u4e0a\u7684\u6240\u6709\u5185\u5bb9\u6388\u4e88 'your-user'@'%';\n<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<hr>\n<h3> \u7ed3\u675f\u8bed <\/h3>\n<ul>\n<li>\u7528\u6237\u7531\u7528\u6237\u540d\u548c\u4e3b\u673a\u552f\u4e00\u6807\u8bc6\u3002 % \u4ee3\u8868\u4efb\u4f55\u4e3b\u673a\uff0c\u5f53\u60a8\u5c06\u7528\u6237\u8bbf\u95ee\u9650\u5236\u4e3a\u4ec5\u67d0\u4e9b\u4e3b\u673a\u65f6\uff08\u4f8b\u5982 your-user%localhost\uff09\uff0c\u547d\u4ee4\u53ef\u80fd\u4f1a\u6709\u6240\u4e0d\u540c\u3002<\/li>\n<li>\u60a8\u53ef\u4ee5\u5c06 Cloud SQL \u4ee3\u7406\u4e0e IAM \u7ed3\u5408\u4f7f\u7528\u3002\u8bf7\u9605\u8bfb IAM \u8eab\u4efd\u9a8c\u8bc1\u6587\u7ae0\u4e86\u89e3\u66f4\u591a\u4fe1\u606f\u3002<\/li>\n<li>\u73b0\u5728\u8fd8\u6709 Cloud SQL Studio [\u9884\u89c8\u7248]\uff0c\u53ef\u80fd\u4f1a\u6d3e\u4e0a\u7528\u573a\u3002<\/li>\n<li>\u6709\u5173 MySQL \u6570\u636e\u5e93\u4e2d\u7528\u6237\u7ba1\u7406\u7684\u66f4\u591a\u4fe1\u606f\u8bf7\u70b9\u51fb\u6b64\u5904\u3002<\/li>\n<\/ul>\n<p>\u4ee5\u4e0a\u5c31\u662f\u521b\u5efa\u53ea\u80fd\u8bbf\u95ee CloudSQL \u4e2d\u4e00\u4e2a\u67b6\u6784\u7684\u7528\u6237\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u7f51\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>TL;DR: \u5728 Google Cloud Console \u4e2d\u521b\u5efa\u7528\u6237\u540e\uff0c\u4e0d\u8981\u5fd8\u8bb0 REVOKE &#8216;cloudsqlsuperuser&#8217;@&#8217;%&#8217; FROM &#8216;your-user&#8217;@&#8217;%&#8217;;\u5982\u679c\u60a8\u53ea\u60f3\u8ba9\u8be5\u7528\u6237\u8bbf\u95ee\u7279\u5b9a\u6a21\u5f0f\u3002 \u901a\u8fc7 Google Cloud Console \u521b\u5efa MySQL \u7528\u6237\u4f1a\u81ea\u52a8\u6dfb\u52a0 cloudsqlsuperuser \u89d2\u8272\uff0c\u8be5\u89d2\u8272\u5141\u8bb8\u7528\u6237\u8bbf\u95ee\u8be5 MySQL \u5b9e\u4f8b\u4e0a\u7684\u6240\u6709\u5185\u5bb9\uff1a \u663e\u793a &#8216;user-from-gcp-console&#8217;@&#8217;%&#8217; \u7684\u8865\u52a9\u91d1\uff1b +&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212; &#8212;&#8212;&#8212;&#8212;+ |\u6388\u4e88 user-from-gcp-console@% | +&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212; &#8212;&#8212;&#8212;&#8212;+ |\u5c06 *.* \u7684\u4f7f\u7528\u6743\u6388\u4e88 `user-from-gcp-console`@`%` | |\u5c06 `cloudsqlsuperuser`@`%` \u6388\u4e88 `user-from-gcp-console`@`%`| +&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212; &#8212;&#8212;&#8212;&#8212;+ \u767b\u5f55\u540e\u590d\u5236 Google \u5728\u5176\u77e5\u8bc6\u5e93\u7684\u5173\u4e8e MySQL \u7528\u6237\u6587\u7ae0\u4e2d\u63d0\u5230\u4e86\u8fd9\u4e00\u70b9\u3002 \u8981\u521b\u5efa\u53ea\u80fd\u8bbf\u95ee\u4e00\u79cd\u67b6\u6784\u7684\u7528\u6237\uff0c\u60a8\u9700\u8981\u901a\u8fc7\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\u6765\u521b\u5efa\u6ca1\u6709\u63a7\u5236\u53f0\u7684\u7528\u6237\uff1a \u521b\u5efa\u7528\u6237\u201c\u60a8\u7684\u7528\u6237\u201d@\u201c%\u201d\u5df2\u8bc6\u522b \u4f7f\u7528\u201cmysql_native_password\u201d BY &#8216;&lt;\u67d0\u4e9b\u5f3a\u5bc6\u7801&gt;&#8217;; \u5c06 your-schema.* \u4e0a\u7684\u6240\u6709\u5185\u5bb9\u6388\u4e88 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-6288","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/6288","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=6288"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/6288\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=6288"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=6288"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=6288"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}