{"id":39762,"date":"2024-11-26T14:17:16","date_gmt":"2024-11-26T06:17:16","guid":{"rendered":"https:\/\/fwq.ai\/blog\/39762\/"},"modified":"2024-11-26T14:17:16","modified_gmt":"2024-11-26T06:17:16","slug":"mysql-dump-and-restorestored-procedures-and-triggers","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/39762\/","title":{"rendered":"MySQL Dump and Restore,Stored Procedures and Triggers"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/246\/273\/173010969451289.jpg\" class=\"aligncenter\" title=\"MySQL Dump and Restore,Stored Procedures and Triggers\u63d2\u56fe\" alt=\"MySQL Dump and Restore,Stored Procedures and Triggers\u63d2\u56fe\" \/><\/p>\n<p><span style=\"color:#1E1E1E;letter-spacing: 2px;border-left:#FF3030 3px solid;border-right:#FF3030 3px solid;padding-left: 8px;padding-right:8px;font-size: 12pt\"><strong>\u4ec0\u4e48\u662f\u5b58\u50a8\u8fc7\u7a0b\uff1f<\/strong><\/span>  <\/p>\n<p> \u5b58\u50a8\u8fc7\u7a0b\uff0c\u662f\u88ab\u5b58\u50a8\u5728\u6570\u636e\u5e93\u4e2d\u7684\u76ee\u5f55\uff0c\u5e76\u4e14\u53ef\u4ee5\u7531\u4e00\u4e2a\u7a0b\u5e8f\u3001\u4e00\u4e2a\u89e6\u53d1\u5668\u6216\u8005\u751a\u81f3\u4e00\u4e2a\u5b58\u50a8\u8fc7\u7a0b\u4ee5\u540e\u8c03\u7528\u7684\u58f0\u660e\u7684SQL\u4ee3\u7801\u6bb5\u3002<\/p>\n<p><span style=\"color:#1E1E1E;letter-spacing: 2px;border-left:#FF3030 3px solid;border-right:#FF3030 3px solid;padding-left: 8px;padding-right:8px;font-size: 12pt\"><strong>\u4ec0\u4e48\u662f\u89e6\u53d1\u5668\uff1f<\/strong><\/span>  <\/p>\n<p> \u89e6\u53d1\u5668\u662f\u4e8b\u4ef6\u9a71\u52a8\u7684\u4e13\u5c5e\u7a0b\u5e8f\uff0c\u5b83\u4eec\u88ab\u5b58\u50a8\u4e0b\u6765\uff0c\u7531\u6570\u636e\u5e93\u7ba1\u7406\u3002\u89e6\u53d1\u5668\u662f\u53d1\u8d77\u4e00\u4e2a\u4e8b\u4ef6\u540e\u89e6\u53d1\u4e00\u4e2aSQL\u8fc7\u7a0b\uff08\u50cf\uff1aINSERT\uff0cDELETE\u6216UPDATE\uff09\u90fd\u53ef\u4ee5\u89e6\u53d1\u3002<\/p>\n<p>\u5f53\u6211\u4eec\u6267\u884cmysqldump \uff0c\u5b83\u4f1a\u81ea\u52a8\u89e6\u53d1\u7684\u5907\u4efd\uff0c\u4f46\u9ed8\u8ba4\u4e0d\u4f1a\u5907\u4efd\u5b58\u50a8\u8fc7\u7a0b\u3002<\/p>\n<p>\u5907\u4efd\u5b58\u50a8\u7a0b\u5e8f\u548c\u5e38\u89c1\u7684\u4f8b\u5b50<\/p>\n<p>\u6211\u4eec\u9700\u8981\u6307\u5b9a -routines \u53c2\u6570\u6765\u5b8c\u6210\u6570\u636e\u548c\u8868\u7684\u5b58\u50a8\u8fc7\u7a0b\u7684\u5907\u4efd\u3002 \u4ee5\u4e0b\u547d\u4ee4\u5c06\u5305\u62ec\u5b58\u50a8\u8fc7\u7a0b\u7684\u6574\u4e2a\u6570\u636e\u5e93\u7684\u5907\u4efd\u3002\u4f8b\u5982\u4f60\u7684\u6570\u636e\u5e93\u540d\u79f0\u4e3a\u201cmydb\u201d\u3002<\/p>\n<pre>\n# mysqldump -u root -p --routines mydb &gt; mydb.sql\n<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u53ea\u5907\u4efd\u5b58\u50a8\u8fc7\u7a0b\u548c\u89e6\u53d1\u5668\uff08\u65e0\u6570\u636e\u548c\u8868\u683c\uff09\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u3002<\/p>\n<pre>\n# mysqldump --routines --no-create-info --no-data --no-create-db --skip-opt mydb &gt; mydb.sql\n<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u6062\u590d\u5b58\u50a8\u8fc7\u7a0b<\/p>\n<p>\u8981\u6062\u590d\u6570\u636e\u5e93\u7684\u5b58\u50a8\u8fc7\u7a0b\u4f7f\u7528\u4e0b\u9762\u7684\u7b80\u5355\u547d\u4ee4\uff0c\u4f46\u8981\u786e\u4fdd\u4f60\u5df2\u7ecf\u5907\u4efd\uff0c\u4ee5\u907f\u514d\u4e4b\u524d\u4efb\u4f55\u6570\u636e\u7684\u4e22\u5931\u3002<\/p>\n<pre>\n# mysql -u root -p mydb\n<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u4ee5\u4e0a\u5c31\u662fMySQL Dump and Restore,Stored Procedures and Triggers\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4ec0\u4e48\u662f\u5b58\u50a8\u8fc7\u7a0b\uff1f \u5b58\u50a8\u8fc7\u7a0b\uff0c\u662f\u88ab\u5b58\u50a8\u5728\u6570\u636e\u5e93\u4e2d\u7684\u76ee\u5f55\uff0c\u5e76\u4e14\u53ef\u4ee5\u7531\u4e00\u4e2a\u7a0b\u5e8f\u3001\u4e00\u4e2a\u89e6\u53d1\u5668\u6216\u8005\u751a\u81f3\u4e00\u4e2a\u5b58\u50a8\u8fc7\u7a0b\u4ee5\u540e\u8c03\u7528\u7684\u58f0\u660e\u7684SQL\u4ee3\u7801\u6bb5\u3002 \u4ec0\u4e48\u662f\u89e6\u53d1\u5668\uff1f \u89e6\u53d1\u5668\u662f\u4e8b\u4ef6\u9a71\u52a8\u7684\u4e13\u5c5e\u7a0b\u5e8f\uff0c\u5b83\u4eec\u88ab\u5b58\u50a8\u4e0b\u6765\uff0c\u7531\u6570\u636e\u5e93\u7ba1\u7406\u3002\u89e6\u53d1\u5668\u662f\u53d1\u8d77\u4e00\u4e2a\u4e8b\u4ef6\u540e\u89e6\u53d1\u4e00\u4e2aSQL\u8fc7\u7a0b\uff08\u50cf\uff1aINSERT\uff0cDELETE\u6216UPDATE\uff09\u90fd\u53ef\u4ee5\u89e6\u53d1\u3002 \u5f53\u6211\u4eec\u6267\u884cmysqldump \uff0c\u5b83\u4f1a\u81ea\u52a8\u89e6\u53d1\u7684\u5907\u4efd\uff0c\u4f46\u9ed8\u8ba4\u4e0d\u4f1a\u5907\u4efd\u5b58\u50a8\u8fc7\u7a0b\u3002 \u5907\u4efd\u5b58\u50a8\u7a0b\u5e8f\u548c\u5e38\u89c1\u7684\u4f8b\u5b50 \u6211\u4eec\u9700\u8981\u6307\u5b9a -routines \u53c2\u6570\u6765\u5b8c\u6210\u6570\u636e\u548c\u8868\u7684\u5b58\u50a8\u8fc7\u7a0b\u7684\u5907\u4efd\u3002 \u4ee5\u4e0b\u547d\u4ee4\u5c06\u5305\u62ec\u5b58\u50a8\u8fc7\u7a0b\u7684\u6574\u4e2a\u6570\u636e\u5e93\u7684\u5907\u4efd\u3002\u4f8b\u5982\u4f60\u7684\u6570\u636e\u5e93\u540d\u79f0\u4e3a\u201cmydb\u201d\u3002 # mysqldump -u root -p &#8211;routines mydb &gt; mydb.sql \u767b\u5f55\u540e\u590d\u5236 \u53ea\u5907\u4efd\u5b58\u50a8\u8fc7\u7a0b\u548c\u89e6\u53d1\u5668\uff08\u65e0\u6570\u636e\u548c\u8868\u683c\uff09\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u3002 # mysqldump &#8211;routines &#8211;no-create-info &#8211;no-data &#8211;no-create-db &#8211;skip-opt mydb &gt; mydb.sql \u767b\u5f55\u540e\u590d\u5236 \u6062\u590d\u5b58\u50a8\u8fc7\u7a0b \u8981\u6062\u590d\u6570\u636e\u5e93\u7684\u5b58\u50a8\u8fc7\u7a0b\u4f7f\u7528\u4e0b\u9762\u7684\u7b80\u5355\u547d\u4ee4\uff0c\u4f46\u8981\u786e\u4fdd\u4f60\u5df2\u7ecf\u5907\u4efd\uff0c\u4ee5\u907f\u514d\u4e4b\u524d\u4efb\u4f55\u6570\u636e\u7684\u4e22\u5931\u3002 # mysql -u root -p mydb \u767b\u5f55\u540e\u590d\u5236 \u4ee5\u4e0a\u5c31\u662fMySQL Dump and Restore,Stored Procedures and Triggers\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[],"class_list":["post-39762","post","type-post","status-publish","format-standard","hentry","category-os"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/39762","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=39762"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/39762\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=39762"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=39762"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=39762"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}