{"id":296268,"date":"2024-05-20T15:57:29","date_gmt":"2024-05-20T07:57:29","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/296268.html"},"modified":"2024-05-20T15:57:36","modified_gmt":"2024-05-20T07:57:36","slug":"mysql-%e6%95%b0%e6%8d%ae%e8%a1%a8%e7%9a%84%e5%ad%97%e7%ac%a6%e5%a6%82%e4%bd%95%e5%af%bc%e5%87%ba","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/296268.html","title":{"rendered":"mysql \u6570\u636e\u8868\u7684\u5b57\u7b26\u5982\u4f55\u5bfc\u51fa"},"content":{"rendered":"<p style=\"text-align:center\"><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/27143651\/eb0415aa-49ed-48eb-83ed-34d42d91d5c9.webp\" alt=\"mysql \u6570\u636e\u8868\u7684\u5b57\u7b26\u5982\u4f55\u5bfc\u51fa\" \/><\/p>\n<p><p>\u5bfc\u51faMySQL\u6570\u636e\u8868\u7684\u5b57\u7b26\u53ef\u4ee5\u901a\u8fc7\u591a\u79cd\u65b9\u6cd5\uff0c\u5305\u62ec\u4f46\u4e0d\u9650\u4e8e<strong>\u4f7f\u7528\u547d\u4ee4\u884c\u5de5\u5177\u3001\u56fe\u5f62\u7528\u6237\u754c\u9762\uff08GUI\uff09\u5de5\u5177\u3001\u6216\u7f16\u7a0b\u8bed\u8a00\u63a5\u53e3<\/strong>\u3002\u5176\u4e2d\uff0c<strong>\u4f7f\u7528\u547d\u4ee4\u884c\u5de5\u5177<\/strong>\u662f\u6700\u76f4\u63a5\u4e14\u5e38\u89c1\u7684\u65b9\u6cd5\u4e4b\u4e00\u3002\u8fd9\u6d89\u53ca\u5230\u4f7f\u7528MySQL\u7684<code>mysqldump<\/code>\u5de5\u5177\uff0c\u5b83\u80fd\u591f\u751f\u6210\u5305\u542b\u6709\u521b\u5efa\u548c\u586b\u5145\u8868\u7684SQL\u8bed\u53e5\u7684\u6587\u4ef6\u3002\u8be5\u5de5\u5177\u4e0d\u4ec5\u652f\u6301\u5bfc\u51fa\u6574\u4e2a\u6570\u636e\u5e93\uff0c\u4e5f\u53ef\u4ee5\u4ec5\u5bfc\u51fa\u7279\u5b9a\u7684\u8868\uff0c\u540c\u65f6\u8fd8\u80fd\u9488\u5bf9\u5bfc\u51fa\u7684\u6570\u636e\u8fdb\u884c\u8fc7\u6ee4\uff0c\u8fd9\u5728\u9700\u8981\u5907\u4efd\u6216\u8fc1\u79fb\u6570\u636e\u65f6\u5c24\u5176\u6709\u7528\u3002<\/p>\n<\/p>\n<p><h2><strong>\u4e00\u3001\u4f7f\u7528MYSQLDUMP\u5de5\u5177\u5bfc\u51fa\u5b57\u7b26<\/strong><\/h2>\n<\/p>\n<p><p>mysqldump\u662fMySQL\u81ea\u5e26\u7684\u4e00\u6b3e\u975e\u5e38\u5b9e\u7528\u7684\u6570\u636e\u5907\u4efd\u7a0b\u5e8f\uff0c\u5b83\u53ef\u4ee5\u751f\u6210\u5305\u542bSQL\u8bed\u53e5\u7684\u6587\u4ef6\uff0c\u7528\u4e8e\u8bb0\u5f55\u6570\u636e\u5e93\u7684\u7ed3\u6784\u548c\u5185\u5bb9\u3002\u8fd9\u4e9bSQL\u8bed\u53e5\u53ef\u7528\u4e8e\u5728\u540c\u4e00\u4e2a\u6216\u4e0d\u540c\u7684MySQL\u670d\u52a1\u5668\u4e0a\u91cd\u65b0\u521b\u5efa\u88ab\u5bfc\u51fa\u7684\u8868\u3002<\/p>\n<\/p>\n<ul>\n<li>\n<p><strong>\u57fa\u672c\u4f7f\u7528\u65b9\u6cd5<\/strong>\uff1a\u8981\u4f7f\u7528mysqldump\u5bfc\u51fa\u4e00\u4e2a\u8868\u7684\u6570\u636e\uff0c\u6700\u57fa\u672c\u7684\u547d\u4ee4\u683c\u5f0f\u4e3a\uff1a<code>mysqldump -u \u7528\u6237\u540d -p\u6570\u636e\u5e93\u540d \u8868\u540d &gt; \u5bfc\u51fa\u7684\u6587\u4ef6\u540d.sql<\/code>\u3002\u6267\u884c\u6b64\u547d\u4ee4\u65f6\uff0c\u7cfb\u7edf\u4f1a\u63d0\u793a\u7528\u6237\u8f93\u5165\u5bc6\u7801\uff0c\u4ee5\u786e\u4fdd\u64cd\u4f5c\u7684\u5b89\u5168\u6027\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u8be6\u7ec6\u9009\u9879\u4ecb\u7ecd<\/strong>\uff1amysqldump\u5de5\u5177\u63d0\u4f9b\u4e86\u4f17\u591a\u9009\u9879\uff0c\u4ee5\u652f\u6301\u4e0d\u540c\u7684\u5bfc\u51fa\u9700\u6c42\u3002\u4f8b\u5982\uff0c<code>--where<\/code>\u9009\u9879\u5141\u8bb8\u7528\u6237\u6307\u5b9a\u6761\u4ef6\u6765\u5bfc\u51fa\u7b26\u5408\u7279\u5b9a\u6761\u4ef6\u7684\u8bb0\u5f55\u3002\u8fd9\u5728\u53ea\u9700\u5bfc\u51fa\u90e8\u5206\u6570\u636e\u65f6\u975e\u5e38\u6709\u7528\u3002\u800c<code>--no-data<\/code>\u9009\u9879\u5219\u5141\u8bb8\u5bfc\u51fa\u8868\u7684\u7ed3\u6784\u800c\u4e0d\u5305\u542b\u4efb\u4f55\u6570\u636e\uff0c\u9002\u7528\u4e8e\u53ea\u9700\u8981\u8868\u7ed3\u6784\u7684\u573a\u666f\u3002<\/p>\n<\/p>\n<\/li>\n<\/ul>\n<p><h2><strong>\u4e8c\u3001\u4f7f\u7528\u56fe\u5f62\u7528\u6237\u754c\u9762\uff08GUI\uff09\u5de5\u5177\u5bfc\u51fa\u5b57\u7b26<\/strong><\/h2>\n<\/p>\n<p><p>\u5bf9\u4e8e\u4e0d\u4e60\u60ef\u4f7f\u7528\u547d\u4ee4\u884c\u7684\u7528\u6237\uff0c\u53ef\u4ee5\u9009\u62e9\u4f7f\u7528\u56fe\u5f62\u7528\u6237\u754c\u9762\uff08GUI\uff09\u5de5\u5177\uff0c\u5982PHPMyAdmin\u3001MySQL Workbench\u7b49\uff0c\u6765\u8fdb\u884c\u6570\u636e\u7684\u5bfc\u51fa\u3002<\/p>\n<\/p>\n<ul>\n<li>\n<p><strong>PHPMyAdmin\u64cd\u4f5c\u6b65\u9aa4<\/strong>\uff1a\u767b\u5f55PHPMyAdmin\uff0c\u9009\u62e9\u76f8\u5e94\u7684\u6570\u636e\u5e93\u548c\u8868\uff0c\u7136\u540e\u70b9\u51fb\u9876\u90e8\u7684\u201c\u5bfc\u51fa\u201d\u9009\u9879\u3002\u5728\u5bfc\u51fa\u9875\u9762\uff0c\u53ef\u4ee5\u9009\u62e9\u591a\u79cd\u683c\u5f0f\u548c\u9009\u9879\uff0c\u6309\u9700\u914d\u7f6e\u540e\u70b9\u51fb\u201c\u6267\u884c\u201d\uff0c\u5373\u53ef\u4e0b\u8f7d\u5305\u542b\u8868\u6570\u636e\u7684\u6587\u4ef6\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>MySQL Workbench\u4f7f\u7528\u6280\u5de7<\/strong>\uff1a\u5728MySQL Workbench\u4e2d\uff0c\u8fde\u63a5\u5230\u6570\u636e\u5e93\u540e\uff0c\u53f3\u952e\u70b9\u51fb\u9700\u8981\u5bfc\u51fa\u7684\u8868\u9009\u62e9\u201cTable Data Export Wizard\u201d\u3002\u8ddf\u968f\u5411\u5bfc\u7684\u6b65\u9aa4\uff0c\u53ef\u4ee5\u9009\u62e9\u5bfc\u51fa\u6570\u636e\u7684\u6587\u4ef6\u683c\u5f0f\u4ee5\u53ca\u5177\u4f53\u7684\u5bfc\u51fa\u9009\u9879\uff0c\u5b8c\u6210\u540e\u70b9\u51fb\u201cStart Export\u201d\u5f00\u59cb\u5bfc\u51fa\u3002<\/p>\n<\/p>\n<\/li>\n<\/ul>\n<p><h2><strong>\u4e09\u3001\u901a\u8fc7\u7f16\u7a0b\u8bed\u8a00\u63a5\u53e3\u5bfc\u51fa\u5b57\u7b26<\/strong><\/h2>\n<\/p>\n<p><p>\u4f7f\u7528\u5982Python\u3001PHP\u7b49\u7f16\u7a0b\u8bed\u8a00\u7684\u6570\u636e\u5e93\u8fde\u63a5\u5e93\uff0c\u4e5f\u53ef\u4ee5\u5b9e\u73b0\u6570\u636e\u7684\u5bfc\u51fa\u529f\u80fd\u3002\u8fd9\u79cd\u65b9\u5f0f\u66f4\u52a0\u7075\u6d3b\uff0c\u9002\u5408\u9700\u8981\u8fdb\u884c\u5b9a\u5236\u5316\u5904\u7406\u7684\u573a\u666f\u3002<\/p>\n<\/p>\n<ul>\n<li>\n<p><strong>Python\u793a\u4f8b<\/strong>\uff1a\u4f7f\u7528Python\u7684pymysql\u6216MySQLdb\u5e93\uff0c\u7ed3\u5408\u6807\u51c6\u7684SQL\u8bed\u53e5\uff0c\u53ef\u4ee5\u8fde\u63a5MySQL\u6570\u636e\u5e93\uff0c\u6267\u884cSELECT\u8bed\u53e5\u63d0\u53d6\u6570\u636e\uff0c\u7136\u540e\u5c06\u7ed3\u679c\u8f93\u51fa\u5230\u6587\u4ef6\u4e2d\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u4ee3\u7801\u5b9e\u8df5<\/strong>\uff1a\u9996\u5148\u5bfc\u5165\u5fc5\u8981\u7684\u5e93\uff0c\u5efa\u7acb\u6570\u636e\u5e93\u8fde\u63a5\uff0c\u7136\u540e\u6267\u884cSELECT\u67e5\u8be2\uff0c\u6700\u540e\u5c06\u67e5\u8be2\u7ed3\u679c\u904d\u5386\u5e76\u5199\u5165\u5230\u6587\u4ef6\uff08CSV\u3001JSON\u7b49\u683c\u5f0f\uff09\u4e2d\u3002\u8fd9\u79cd\u65b9\u6cd5\u7684\u4f18\u52bf\u5728\u4e8e\u53ef\u4ee5\u5728\u6570\u636e\u5bfc\u51fa\u8fc7\u7a0b\u4e2d\u8fdb\u884c\u52a8\u6001\u7684\u5904\u7406\u548c\u8fc7\u6ee4\u3002<\/p>\n<\/p>\n<\/li>\n<\/ul>\n<p><h2><strong>\u56db\u3001\u603b\u7ed3\u4e0e\u6700\u4f73\u5b9e\u8df5<\/strong><\/h2>\n<\/p>\n<p><p>\u5728\u9009\u62e9\u5bfc\u51fa\u65b9\u6cd5\u65f6\uff0c\u9700\u8981\u6839\u636e\u5b9e\u9645\u7684\u9700\u6c42\u548c\u64cd\u4f5c\u73af\u5883\u6765\u51b3\u5b9a\u3002<strong>\u4f7f\u7528\u547d\u4ee4\u884c\u5de5\u5177<\/strong>\u5bf9\u4e8e\u8ffd\u6c42\u6548\u7387\u548c\u81ea\u52a8\u5316\u7684\u7528\u6237\u6765\u8bf4\u662f\u6700\u76f4\u63a5\u7684\u9009\u62e9\uff1b<strong>\u4f7f\u7528GUI\u5de5\u5177<\/strong>\u5219\u66f4\u9002\u5408\u89c6\u89c9\u64cd\u4f5c\uff0c\u4fbf\u4e8e\u76f4\u89c2\u7406\u89e3\uff1b\u800c<strong>\u901a\u8fc7\u7f16\u7a0b\u8bed\u8a00\u63a5\u53e3<\/strong>\u5219\u63d0\u4f9b\u4e86\u6700\u5927\u7684\u7075\u6d3b\u5ea6\u548c\u5b9a\u5236\u80fd\u529b\u3002<\/p>\n<\/p>\n<ul>\n<li>\n<p><strong>\u4fdd\u969c\u5b89\u5168\u6027<\/strong>\uff1a\u64cd\u4f5c\u6570\u636e\u5bfc\u51fa\u65f6\u9700\u786e\u4fdd\u6570\u636e\u7684\u5b89\u5168\u6027\uff0c\u907f\u514d\u654f\u611f\u4fe1\u606f\u6cc4\u9732\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u5b9a\u671f\u5907\u4efd<\/strong>\uff1a\u65e0\u8bba\u662f\u51fa\u4e8e\u6570\u636e\u8fc1\u79fb\u8fd8\u662f\u5907\u4efd\u7684\u9700\u8981\uff0c\u5b9a\u671f\u5bfc\u51fa\u6570\u636e\u662f\u4e00\u79cd\u826f\u597d\u7684\u5b9e\u8df5\uff0c\u6709\u52a9\u4e8e\u6570\u636e\u7684\u6062\u590d\u548c\u7ba1\u7406\u3002<\/p>\n<\/p>\n<\/li>\n<\/ul>\n<p><p>\u901a\u8fc7\u638c\u63e1\u4e0a\u8ff0\u591a\u79cd\u65b9\u6cd5\uff0c\u53ef\u4ee5\u7075\u6d3b\u5730\u5e94\u5bf9\u4e0d\u540c\u573a\u666f\u4e0b\u7684\u6570\u636e\u5bfc\u51fa\u9700\u6c42\uff0c\u786e\u4fdd\u6570\u636e\u7684\u5b8c\u6574\u6027\u548c\u4e00\u81f4\u6027\u5728\u64cd\u4f5c\u8fc7\u7a0b\u4e2d\u5f97\u5230\u7ef4\u62a4\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p><strong>1. \u5982\u4f55\u5bfc\u51fa MySQL \u6570\u636e\u8868\u7684\u5b57\u7b26\u96c6\uff1f<\/strong><\/p>\n<p>\u5982\u679c\u4f60\u60f3\u8981\u5bfc\u51fa MySQL \u6570\u636e\u8868\u7684\u5b57\u7b26\u96c6\uff0c\u53ef\u4ee5\u6309\u7167\u4ee5\u4e0b\u6b65\u9aa4\u8fdb\u884c\u64cd\u4f5c\uff1a<\/p>\n<ul>\n<li>\u9996\u5148\uff0c\u767b\u5f55\u5230 MySQL \u6570\u636e\u5e93\u3002<\/li>\n<li>\u7136\u540e\uff0c\u4f7f\u7528<code>SHOW CREATE TABLE<\/code>\u8bed\u53e5\u6765\u83b7\u53d6\u6570\u636e\u8868\u7684\u521b\u5efa\u8bed\u53e5\u3002<\/li>\n<li>\u5728\u521b\u5efa\u8bed\u53e5\u4e2d\uff0c\u4f60\u53ef\u4ee5\u627e\u5230\u6570\u636e\u8868\u7684\u5b57\u7b26\u96c6\uff08\u5982UTF-8\uff09\u3002<\/li>\n<li>\u6700\u540e\uff0c\u4f60\u53ef\u4ee5\u5c06\u521b\u5efa\u8bed\u53e5\u590d\u5236\u5e76\u4fdd\u5b58\u6210\u4e00\u4e2a\u6587\u4ef6\uff0c\u5373\u53ef\u5bfc\u51fa\u6570\u636e\u8868\u7684\u5b57\u7b26\u96c6\u4fe1\u606f\u3002<\/li>\n<\/ul>\n<p><strong>2. MySQL \u6570\u636e\u8868\u7684\u5b57\u7b26\u96c6\u548c\u6392\u5e8f\u89c4\u5219\u6709\u4ec0\u4e48\u5173\u7cfb\uff1f<\/strong><\/p>\n<p>\u5728 MySQL \u6570\u636e\u5e93\u4e2d\uff0c\u5b57\u7b26\u96c6\u51b3\u5b9a\u4e86\u53ef\u4ee5\u5728\u6570\u636e\u8868\u4e2d\u5b58\u50a8\u7684\u5b57\u7b26\u7c7b\u578b\u548c\u7f16\u7801\uff0c\u800c\u6392\u5e8f\u89c4\u5219\u5219\u51b3\u5b9a\u4e86\u5b57\u7b26\u4e4b\u95f4\u7684\u6bd4\u8f83\u548c\u6392\u5e8f\u65b9\u5f0f\u3002\u5b57\u7b26\u96c6\u548c\u6392\u5e8f\u89c4\u5219\u662f\u7d27\u5bc6\u76f8\u5173\u7684\uff0c\u56e0\u4e3a\u5b83\u4eec\u4e00\u8d77\u51b3\u5b9a\u4e86\u5982\u4f55\u5904\u7406\u548c\u6bd4\u8f83\u4e0d\u540c\u5b57\u7b26\u3002<\/p>\n<p>\u4f8b\u5982\uff0c\u5982\u679c\u6570\u636e\u8868\u7684\u5b57\u7b26\u96c6\u4e3aUTF-8\uff0c\u6392\u5e8f\u89c4\u5219\u4e3autf8_general_ci\uff08\u4e0d\u533a\u5206\u5927\u5c0f\u5199\u7684\u5b57\u5178\u987a\u5e8f\uff09\uff0c\u90a3\u4e48\u5728\u6bd4\u8f83\u548c\u6392\u5e8f\u5b57\u7b26\u65f6\uff0c\u4f1a\u5ffd\u7565\u5927\u5c0f\u5199\u5e76\u6309\u7167\u5b57\u5178\u987a\u5e8f\u8fdb\u884c\u6bd4\u8f83\u3002<\/p>\n<p><strong>3. \u5982\u4f55\u5c06 MySQL \u6570\u636e\u8868\u5bfc\u51fa\u4e3a\u7279\u5b9a\u5b57\u7b26\u96c6\u7684 SQL \u6587\u4ef6\uff1f<\/strong><\/p>\n<p>\u5982\u679c\u4f60\u60f3\u8981\u5c06 MySQL \u6570\u636e\u8868\u5bfc\u51fa\u4e3a\u7279\u5b9a\u5b57\u7b26\u96c6\u7684 SQL \u6587\u4ef6\uff0c\u53ef\u4ee5\u6309\u7167\u4ee5\u4e0b\u6b65\u9aa4\u8fdb\u884c\u64cd\u4f5c\uff1a<\/p>\n<ul>\n<li>\u9996\u5148\uff0c\u4f7f\u7528<code>mysqldump<\/code>\u547d\u4ee4\u884c\u5de5\u5177\u5bfc\u51fa\u6574\u4e2a\u6570\u636e\u5e93\u6216\u7279\u5b9a\u6570\u636e\u8868\u7684\u6570\u636e\u3002<\/li>\n<li>\u5728\u547d\u4ee4\u4e2d\u6dfb\u52a0<code>--default-character-set<\/code>\u53c2\u6570\uff0c\u540e\u9762\u8ddf\u4e0a\u76ee\u6807\u5b57\u7b26\u96c6\u7684\u540d\u79f0\u3002<\/li>\n<li>\u7136\u540e\uff0c\u5c06\u5bfc\u51fa\u7684\u6570\u636e\u4fdd\u5b58\u5230\u4e00\u4e2a SQL \u6587\u4ef6\u4e2d\uff0c\u4f7f\u7528<code>&gt;<\/code>\u7b26\u53f7\u6307\u5b9a\u8f93\u51fa\u6587\u4ef6\u3002<\/li>\n<li>\u6700\u540e\uff0c\u8fd0\u884c\u547d\u4ee4\uff0c\u5373\u53ef\u5c06\u6570\u636e\u5bfc\u51fa\u4e3a\u7279\u5b9a\u5b57\u7b26\u96c6\u7684 SQL \u6587\u4ef6\u3002<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"\u5bfc\u51faMySQL\u6570\u636e\u8868\u7684\u5b57\u7b26\u53ef\u4ee5\u901a\u8fc7\u591a\u79cd\u65b9\u6cd5\uff0c\u5305\u62ec\u4f46\u4e0d\u9650\u4e8e\u4f7f\u7528\u547d\u4ee4\u884c\u5de5\u5177\u3001\u56fe\u5f62\u7528\u6237\u754c\u9762\uff08GUI\uff09\u5de5\u5177\u3001\u6216\u7f16\u7a0b\u8bed\u8a00 [&hellip;]","protected":false},"author":3,"featured_media":296273,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[37],"tags":[],"acf":[],"_links":{"self":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/296268"}],"collection":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/comments?post=296268"}],"version-history":[{"count":0,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/296268\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/296273"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=296268"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=296268"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=296268"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}