{"id":5164,"date":"2024-11-14T08:51:11","date_gmt":"2024-11-14T00:51:11","guid":{"rendered":"https:\/\/fwq.ai\/blog\/5164\/"},"modified":"2024-11-14T08:51:11","modified_gmt":"2024-11-14T00:51:11","slug":"mysql%e6%80%8e%e4%b9%88%e6%94%b9%e7%bc%96%e7%a0%81%e6%a0%bc%e5%bc%8f","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/5164\/","title":{"rendered":"mysql\u600e\u4e48\u6539\u7f16\u7801\u683c\u5f0f"},"content":{"rendered":"<blockquote><p>\n  \u8981\u66f4\u6539 mysql \u6570\u636e\u5e93\u7684\u7f16\u7801\u683c\u5f0f\uff0c\u9700\u4f9d\u6b21\u6267\u884c\u4ee5\u4e0b\u6b65\u9aa4\uff1a\u5bfc\u51fa\u6570\u636e\u5e93\uff0c\u6307\u5b9a\u6240\u9700\u7f16\u7801\u683c\u5f0f\u5220\u9664\u73b0\u6709\u6570\u636e\u5e93\u521b\u5efa\u65b0\u6570\u636e\u5e93\uff0c\u6307\u5b9a\u6240\u9700\u7f16\u7801\u683c\u5f0f\u5bfc\u5165\u6570\u636e\u9a8c\u8bc1\u7f16\u7801\u683c\u5f0f\u662f\u5426\u5df2\u66f4\u6539\n<\/p><\/blockquote>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/202405\/22\/2024052218003222007.jpg\" class=\"aligncenter\" title=\"mysql\u600e\u4e48\u6539\u7f16\u7801\u683c\u5f0f\u63d2\u56fe\" alt=\"mysql\u600e\u4e48\u6539\u7f16\u7801\u683c\u5f0f\u63d2\u56fe\" \/><\/p>\n<p><strong>MySQL \u66f4\u6539\u7f16\u7801\u683c\u5f0f<\/strong><\/p>\n<p><strong>\u5982\u4f55\u66f4\u6539 MySQL \u6570\u636e\u5e93\u7684\u7f16\u7801\u683c\u5f0f\uff1f<\/strong><\/p>\n<p>\u66f4\u6539 MySQL \u6570\u636e\u5e93\u7684\u7f16\u7801\u683c\u5f0f\u6d89\u53ca\u4ee5\u4e0b\u6b65\u9aa4\uff1a<\/p>\n<p><strong>1. \u5bfc\u51fa\u6570\u636e\u5e93<\/strong><\/p>\n<p>\u4f7f\u7528 dump \u547d\u4ee4\u5c06\u6570\u636e\u5e93\u5bfc\u51fa\u4e3a SQL \u6587\u4ef6\uff0c\u5e76\u6307\u5b9a\u6240\u9700\u7684\u7f16\u7801\u683c\u5f0f\u3002\u4f8b\u5982\uff1a<\/p>\n<pre>mysqldump -u &lt;\u7528\u6237\u540d&gt; -p &lt;\u6570\u636e\u5e93\u540d&gt; --default-character-set=utf8 &gt; database_backup.sql<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>2. \u5220\u9664\u73b0\u6709\u6570\u636e\u5e93<\/strong><\/p>\n<p>\u5220\u9664\u8981\u66f4\u6539\u7f16\u7801\u683c\u5f0f\u7684\u73b0\u6709\u6570\u636e\u5e93\u3002<\/p>\n<pre>DROP DATABASE &lt;\u6570\u636e\u5e93\u540d&gt;;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>3. \u521b\u5efa\u65b0\u6570\u636e\u5e93<\/strong><\/p>\n<p>\u4f7f\u7528\u6240\u9700\u7684\u7f16\u7801\u683c\u5f0f\u521b\u5efa\u65b0\u6570\u636e\u5e93\u3002<\/p>\n<pre>CREATE DATABASE &lt;\u6570\u636e\u5e93\u540d&gt; CHARACTER SET &lt;\u7f16\u7801\u683c\u5f0f&gt;;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>4. \u5bfc\u5165\u6570\u636e<\/strong><\/p>\n<p>\u4f7f\u7528\u5bfc\u51fa\u7684 SQL \u6587\u4ef6\u5c06\u6570\u636e\u5bfc\u5165\u65b0\u6570\u636e\u5e93\u3002<\/p>\n<pre>mysql -u &lt;\u7528\u6237\u540d&gt; -p &lt;\u6570\u636e\u5e93\u540d&gt; &lt; database_backup.sql<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>5. \u9a8c\u8bc1\u7f16\u7801\u683c\u5f0f<\/strong><\/p>\n<p>\u4f7f\u7528 SHOW VARIABLES \u547d\u4ee4\u9a8c\u8bc1\u7f16\u7801\u683c\u5f0f\u662f\u5426\u5df2\u66f4\u6539\u3002<\/p>\n<pre>SHOW VARIABLES LIKE 'character_set%';<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>\u63d0\u793a\uff1a<\/strong><\/p>\n<ul>\n<li>\u786e\u4fdd\u5728\u5bfc\u51fa\u548c\u5bfc\u5165\u8fc7\u7a0b\u4e2d\u6307\u5b9a\u76f8\u540c\u7684\u7f16\u7801\u683c\u5f0f\u3002<\/li>\n<li>\u66f4\u6539\u7f16\u7801\u683c\u5f0f\u53ef\u80fd\u4f1a\u5f71\u54cd\u6570\u636e\u5e93\u4e2d\u7684\u6570\u636e\uff0c\u56e0\u6b64\u5728\u8fdb\u884c\u66f4\u6539\u4e4b\u524d\u8fdb\u884c\u5907\u4efd\u975e\u5e38\u91cd\u8981\u3002<\/li>\n<li>\u67d0\u4e9b\u5b57\u7b26\u96c6\u53ef\u80fd\u4f1a\u4e0e\u67d0\u4e9b\u5b57\u7b26\u96c6\u4e0d\u517c\u5bb9\uff0c\u56e0\u6b64\u5728\u66f4\u6539\u7f16\u7801\u683c\u5f0f\u4e4b\u524d\u8bf7\u5148\u8fdb\u884c\u7814\u7a76\u3002<\/li>\n<li>\u5982\u679c\u66f4\u6539\u7f16\u7801\u683c\u5f0f\u540e\u9047\u5230\u95ee\u9898\uff0c\u53ef\u4ee5\u5c1d\u8bd5\u4f7f\u7528 ALTER DATABASE \u547d\u4ee4\u8fd8\u539f\u4e3a\u4ee5\u524d\u7684\u7f16\u7801\u683c\u5f0f\u3002<\/li>\n<\/ul>\n<p>\u4ee5\u4e0a\u5c31\u662f\u600e\u4e48\u6539\u7f16\u7801\u683c\u5f0f\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>\u8981\u66f4\u6539 mysql \u6570\u636e\u5e93\u7684\u7f16\u7801\u683c\u5f0f\uff0c\u9700\u4f9d\u6b21\u6267\u884c\u4ee5\u4e0b\u6b65\u9aa4\uff1a\u5bfc\u51fa\u6570\u636e\u5e93\uff0c\u6307\u5b9a\u6240\u9700\u7f16\u7801\u683c\u5f0f\u5220\u9664\u73b0\u6709\u6570\u636e\u5e93\u521b\u5efa\u65b0\u6570\u636e\u5e93\uff0c\u6307\u5b9a\u6240\u9700\u7f16\u7801\u683c\u5f0f\u5bfc\u5165\u6570\u636e\u9a8c\u8bc1\u7f16\u7801\u683c\u5f0f\u662f\u5426\u5df2\u66f4\u6539 MySQL \u66f4\u6539\u7f16\u7801\u683c\u5f0f \u5982\u4f55\u66f4\u6539 MySQL \u6570\u636e\u5e93\u7684\u7f16\u7801\u683c\u5f0f\uff1f \u66f4\u6539 MySQL \u6570\u636e\u5e93\u7684\u7f16\u7801\u683c\u5f0f\u6d89\u53ca\u4ee5\u4e0b\u6b65\u9aa4\uff1a 1. \u5bfc\u51fa\u6570\u636e\u5e93 \u4f7f\u7528 dump \u547d\u4ee4\u5c06\u6570\u636e\u5e93\u5bfc\u51fa\u4e3a SQL \u6587\u4ef6\uff0c\u5e76\u6307\u5b9a\u6240\u9700\u7684\u7f16\u7801\u683c\u5f0f\u3002\u4f8b\u5982\uff1a mysqldump -u &lt;\u7528\u6237\u540d&gt; -p &lt;\u6570\u636e\u5e93\u540d&gt; &#8211;default-character-set=utf8 &gt; database_backup.sql \u767b\u5f55\u540e\u590d\u5236 2. \u5220\u9664\u73b0\u6709\u6570\u636e\u5e93 \u5220\u9664\u8981\u66f4\u6539\u7f16\u7801\u683c\u5f0f\u7684\u73b0\u6709\u6570\u636e\u5e93\u3002 DROP DATABASE &lt;\u6570\u636e\u5e93\u540d&gt;; \u767b\u5f55\u540e\u590d\u5236 3. \u521b\u5efa\u65b0\u6570\u636e\u5e93 \u4f7f\u7528\u6240\u9700\u7684\u7f16\u7801\u683c\u5f0f\u521b\u5efa\u65b0\u6570\u636e\u5e93\u3002 CREATE DATABASE &lt;\u6570\u636e\u5e93\u540d&gt; CHARACTER SET &lt;\u7f16\u7801\u683c\u5f0f&gt;; \u767b\u5f55\u540e\u590d\u5236 4. \u5bfc\u5165\u6570\u636e \u4f7f\u7528\u5bfc\u51fa\u7684 SQL \u6587\u4ef6\u5c06\u6570\u636e\u5bfc\u5165\u65b0\u6570\u636e\u5e93\u3002 mysql -u &lt;\u7528\u6237\u540d&gt; -p &lt;\u6570\u636e\u5e93\u540d&gt; &lt; [&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-5164","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/5164","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=5164"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/5164\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=5164"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=5164"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=5164"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}