{"id":200675,"date":"2025-05-06T08:11:16","date_gmt":"2025-05-06T00:11:16","guid":{"rendered":"https:\/\/server.hk\/cnblog\/200675\/"},"modified":"2025-05-06T08:11:16","modified_gmt":"2025-05-06T00:11:16","slug":"%e5%a6%82%e4%bd%95%e4%bd%bf%e7%94%a8-shell-%e8%84%9a%e6%9c%ac%e5%ae%9e%e6%97%b6%e6%89%93%e5%8d%b0%e6%89%a7%e8%a1%8c-sql-%e7%9a%84%e8%bf%87%e7%a8%8b%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/200675\/","title":{"rendered":"\u5982\u4f55\u4f7f\u7528 shell \u811a\u672c\u5b9e\u65f6\u6253\u5370\u6267\u884c SQL \u7684\u8fc7\u7a0b\uff1f"},"content":{"rendered":"<p><b><\/b> <\/p>\n<h1>\u5982\u4f55\u4f7f\u7528 shell \u811a\u672c\u5b9e\u65f6\u6253\u5370\u6267\u884c SQL \u7684\u8fc7\u7a0b\uff1f<\/h1>\n<p>\u4eca\u5929\u4e3b\u673a\u5b9d\u8d1d\u7ed9\u5927\u5bb6\u5e26\u6765\u4e86\uff0c\u5176\u4e2d\u6d89\u53ca\u5230\u7684\u77e5\u8bc6\u70b9\u5305\u62ec\u7b49\u7b49\uff0c\u65e0\u8bba\u4f60\u662f\u5c0f\u767d\u8fd8\u662f\u8001\u624b\uff0c\u90fd\u9002\u5408\u770b\u4e00\u770b\u54e6~\u6709\u597d\u7684\u5efa\u8bae\u4e5f\u6b22\u8fce\u5927\u5bb6\u5728\u8bc4\u8bba\u7559\u8a00\uff0c\u82e5\u662f\u770b\u5b8c\u6709\u6240\u6536\u83b7\uff0c\u4e5f\u5e0c\u671b\u5927\u5bb6\u80fd\u591a\u591a\u70b9\u8d5e\u652f\u6301\u5440\uff01\u4e00\u8d77\u52a0\u6cb9\u5b66\u4e60~<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.17golang.com\/uploads\/20241111\/173130250567319469c39bc.jpg\" class=\"aligncenter\"><\/p>\n<p><strong>\u5982\u4f55\u4f7f\u7528 shell \u811a\u672c\u5b9e\u65f6\u6253\u5370\u6267\u884c sql \u7684\u8fc7\u7a0b<\/strong><\/p>\n<p>\u4f60\u7684 shell \u811a\u672c\u901a\u8fc7 mysql \u547d\u4ee4\u6267\u884c sql \u811a\u672c\uff0c\u4f46\u662f\u6267\u884c\u540e\u4f1a\u5361\u6b7b\uff0c\u65e0\u6cd5\u5b9e\u65f6\u770b\u5230\u7ed3\u679c\u3002\u4e3a\u4e86\u89e3\u51b3\u8fd9\u4e2a\u95ee\u9898\uff0c\u53ef\u4ee5\u4f7f\u7528 -v \u53c2\u6570\u8fdb\u884c\u4f18\u5316\u3002<\/p>\n<p>-v \u53c2\u6570\u5141\u8bb8 mysql \u547d\u4ee4\u5728\u6267\u884c sql \u8bed\u53e5\u65f6\u8f93\u51fa\u989d\u5916\u7684\u4fe1\u606f\u3002\u5177\u4f53\u6765\u8bf4\uff0c\u5b83\u4f1a\u6253\u5370\u6bcf\u4e2a\u8bed\u53e5\u7684\u72b6\u6001\u4fe1\u606f\uff0c\u5982\uff1a<\/p>\n<pre>query ok, 1 row affected (0.00 sec)\nrecords: 1  duplicates: 0  warnings: 0<\/pre>\n<p>\u901a\u8fc7\u5728\u4f60\u7684\u811a\u672c\u4e2d\u6dfb\u52a0 -v \u53c2\u6570\uff0c\u5373\u53ef\u5b9e\u65f6\u6253\u5370\u6267\u884c sql \u7684\u8fc7\u7a0b\uff0c\u5982\u4e0b\u6240\u793a\uff1a<\/p>\n<pre>mysql -vvv -h$mysqlhost -uroot -p$rootpwd -P$mysqlport -e \\\n\"use mysql;source ${basepath}\/sql_execute\/apphub\/apphub_mysql_db_create.sql;\nsource ${basepath}\/sql_execute\/bam\/bam_mysql_db_create.sql;  \nsource ${basepath}\/sql_execute\/bim\/bim_mysql_db_create.sql; \nsource ${basepath}\/sql_execute\/epass\/epass_mysql_db_create.sql; \nuse apphub${suffix}; \nsource ${basepath}\/sql_execute\/apphub\/apphub_mysql_table_and_data.sql; \nuse bam${suffix}; \nsource ${basepath}\/sql_execute\/bam\/bam_mysql_table_and_data.sql; \nuse bim${suffix}; \nsource ${basepath}\/sql_execute\/bim\/bim_mysql_table_and_data.sql; \nuse epass${suffix}; \nsource ${basepath}\/sql_execute\/epass\/epass_mysql_table_and_data.sql;\" &gt; ${basepath}\/running_sql.log &amp;amp;<\/pre>\n<p>\u9700\u8981\u6ce8\u610f\u7684\u662f\uff0cmysql -v \u7684\u8f93\u51fa\u53ef\u80fd\u8f83\u591a\uff0c\u56e0\u6b64\u4f60\u9700\u8981\u5408\u7406\u5730\u5904\u7406\u8fd9\u4e9b\u4fe1\u606f\uff0c\u4fdd\u8bc1\u811a\u672c\u7684\u5065\u58ee\u6027\u3002<\/p>\n<p>\u5230\u8fd9\u91cc\uff0c\u6211\u4eec\u4e5f\u5c31\u8bb2\u5b8c\u4e86\u300a\u5982\u4f55\u4f7f\u7528 shell \u811a\u672c\u5b9e\u65f6\u6253\u5370\u6267\u884c SQL \u7684\u8fc7\u7a0b\uff1f\u300b\u7684\u5185\u5bb9\u4e86\u3002\u4e2a\u4eba\u8ba4\u4e3a\uff0c\u57fa\u7840\u77e5\u8bc6\u7684\u5b66\u4e60\u548c\u5de9\u56fa\uff0c\u662f\u4e3a\u4e86\u66f4\u597d\u7684\u5c06\u5176\u8fd0\u7528\u5230\u9879\u76ee\u4e2d\uff0c\u6b22\u8fce\u5173\u6ce8\u4e3b\u673a\u5b9d\u8d1d\u516c\u4f17\u53f7\uff0c\u5e26\u4f60\u4e86\u89e3\u66f4\u591a\u5173\u4e8e\u7684\u77e5\u8bc6\u70b9\uff01<\/p>\n<dl>\n<dt>\n <\/dt>\n<\/dl>\n","protected":false},"excerpt":{"rendered":"<p>\u5982\u4f55\u4f7f\u7528 shell \u811a\u672c\u5b9e\u65f6\u6253&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[101],"tags":[],"class_list":["post-200675","post","type-post","status-publish","format-standard","hentry","category-database"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/200675","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"}],"author":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/comments?post=200675"}],"version-history":[{"count":0,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/200675\/revisions"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=200675"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=200675"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=200675"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}