{"id":851,"date":"2024-06-05T20:36:06","date_gmt":"2024-06-05T12:36:06","guid":{"rendered":"https:\/\/cn.raksmart.com\/blog\/host\/4198.html"},"modified":"2024-06-05T20:36:06","modified_gmt":"2024-06-05T12:36:06","slug":"mysql%e5%a4%87%e4%bb%bd%e6%97%b6%e5%87%ba%e7%8e%b0%e9%94%99%e8%af%af%e8%af%a5%e6%80%8e%e4%b9%88%e5%8a%9e","status":"publish","type":"post","link":"https:\/\/cn.raksmart.com\/blog\/%e6%8a%80%e6%9c%af%e6%95%99%e7%a8%8b\/%e4%ba%91%e6%9c%8d%e5%8a%a1-%e6%8a%80%e6%9c%af%e6%95%99%e7%a8%8b\/851.html","title":{"rendered":"MySQL\u5907\u4efd\u65f6\u51fa\u73b0\u9519\u8bef\u8be5\u600e\u4e48\u529e"},"content":{"rendered":"<div class=\"entry-content e-content\" itemprop=\"description articleBody\">\n<p>\u4eca\u5929\u6709\u4e2a\u7f51\u53cb\u95ee\uff0c\u5728\u7528<a href=\"https:\/\/www.raksmart.com\/cps\/7921\" target=\"_blank\" rel=\"noopener\">mysql<\/a>dump\u5907\u4efd\u65f6\u5019\u9047\u52301290\u7684\u9519\u8bef\u3002\u672c\u6587Raksmart<strong><a href=\"https:\/\/cn.raksmart.com\/\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\"\u72ec\u7acb\u670d\u52a1\u5668\uff08\u5728\u65b0\u7a97\u53e3\u6253\u5f00\uff09\">\u72ec\u7acb\u670d\u52a1\u5668<\/a><\/strong>\u5546\u5c31\u5982\u4f55\u5728\u670d\u52a1\u5668\u5229\u7528<a href=\"https:\/\/www.raksmart.com\/cps\/7921\" target=\"_blank\" rel=\"noopener\">MySQL<\/a>\u5907\u4efd\u6570\u636e\u51fa\u73b0\u7684\u95ee\u9898\u505a\u4e00\u4e9b\u76f8\u5173\u4ecb\u7ecd\u3002<\/p>\n<p>\u4e0b\u9762\u662f\u6211\u6a21\u62df\u4ed6\u7684\u62a5\u9519\u4fe1\u606f\uff1a<\/p>\n<p>\uff3broot@potato Desktop\uff3d# mysqldump -uroot -proot -S \/tmp\/mysql.sock<br \/>\n\u2013tab=\/data\/mysql\/mytest_3306\/data\/backup lala<\/p>\n<p>Warning\uff1a Using a password on the command line interface can be insecure.<\/p>\n<p>mysqldump\uff1a Got error\uff1a 1290\uff1a The MySQL server is running with the<br \/>\n\u2013secure-file-priv option so it cannot execute this statement when executing<br \/>\n\u2018SELECT INTO OUTFILE\u2019 \u3002<\/p>\n<p>\u53ef\u4ee5\u5f88\u6e05\u695a\u5730\u4ece\u63d0\u793a\u770b\u5230\u662f\u56e0\u4e3amysql\u670d\u52a1\u542f\u7528\u4e86\u2013secure-file-priv\uff0c\u6240\u4ee5\u624d\u65e0\u6cd5\u6267\u884c\u3002<\/p>\n<p>\u90a3\u4e48\u2013secure-file-priv\u53c8\u662f\u4ec0\u4e48\u4e1c\u897f\uff0c\u5e94\u8be5\u5982\u4f55\u89e3\u51b3\u624d\u80fd\u662f\u5b83\u53ef\u4ee5\u5907\u4efd\u5462\uff1f<\/p>\n<p>\u2013secure-file-priv=name \uff1a<\/p>\n<p>Limit LOAD DATA\uff0c SELECT \u3002.. OUTFILE\uff0c and LOAD_FILE\uff08\uff09 to files within<br \/>\nspecified directory<\/p>\n<p>\u53ef\u4ee5\u770b\u5230secure-file-priv\u53c2\u6570\u662f\u7528\u6765\u9650\u5236LOAD DATA\uff0c SELECT \u3002.. OUTFILE\uff0c and<br \/>\nLOAD_FILE\uff08\uff09\u4f20\u5230\u54ea\u4e2a\u6307\u5b9a\u76ee\u5f55\u7684\u3002<\/p>\n<p>\u5f53secure_file_priv\u7684\u503c\u4e3anull \uff0c\u8868\u793a\u9650\u5236mysqld \u4e0d\u5141\u8bb8\u5bfc\u5165|\u5bfc\u51fa<\/p>\n<p>\u5f53secure_file_priv\u7684\u503c\u4e3a\/tmp\/ \uff0c\u8868\u793a\u9650\u5236mysqld \u7684\u5bfc\u5165|\u5bfc\u51fa\u53ea\u80fd\u53d1\u751f\u5728\/tmp\/\u76ee\u5f55\u4e0b<\/p>\n<p>\u5f53secure_file_priv\u7684\u503c\u6ca1\u6709\u5177\u4f53\u503c\u65f6\uff0c\u8868\u793a\u4e0d\u5bf9mysqld \u7684\u5bfc\u5165|\u5bfc\u51fa\u505a\u9650\u5236<\/p>\n<p>\u67e5\u770b\u6570\u636e\u5e93\u5f53\u524d\u8be5\u53c2\u6570\u7684\u503c\u3002<\/p>\n<p>root@localhost:mysql.sock 00:14:52 \uff3b\uff08none\uff09\uff3d\u300bshow global variables like<br \/>\n\u2018%secure%\u2019;<\/p>\n<p>+\u2014\u2014\u2014\u2014\u2014\u2014+\u2014\u2014-+<\/p>\n<p>| Variable_name | Value |<\/p>\n<p>+\u2014\u2014\u2014\u2014\u2014\u2014+\u2014\u2014-+<\/p>\n<p>| secure_auth | ON |<\/p>\n<p>| secure_file_priv | NULL |<\/p>\n<p>+\u2014\u2014\u2014\u2014\u2014\u2014+\u2014\u2014-+<\/p>\n<p>2 rows in set \uff080.00 sec\uff09<\/p>\n<p>\u6e05\u695a\u5730\u770b\u5230secure_file_priv \u7684\u503c\u662fNULL\uff0c\u8bf4\u660e\u6b64\u65f6\u9650\u5236\u5bfc\u5165\u5bfc\u51fa\u7684\u3002<\/p>\n<p>\u6240\u4ee5\u5e94\u8be5\u6539\u53d8\u8be5\u53c2\u6570\u3002<\/p>\n<p>\u53ef\u662f\u67e5\u770b\u4e86mysql.cnf\u4e2d\u5c45\u7136\u6ca1\u6709\u5bf9\u8fd9\u4e2a\u53c2\u6570\u8fdb\u884c\u8bbe\u5b9a\uff0c\u5c31\u8bf4\u660e\u8fd9\u4e2a\u53c2\u6570\u9ed8\u8ba4\u4fbf\u662fnull<\/p>\n<p>\u6240\u4ee5\u518dmysql.cnf\u4e2d\u7684\uff3bmysqld\uff3d\u52a0\u5165secure_file_priv =<\/p>\n<p>\u518d\u91cd\u542fmysql\u670d\u52a1\uff1a<\/p>\n<p>\u7136\u540e\u518d\u67e5\u4e00\u4e0b\u6b64\u65f6\u53c2\u6570\u7684\u503c\uff1a<\/p>\n<p>root@localhost:mysql.sock 00:28:30 \uff3b\uff08none\uff09\uff3d\u300bshow global variables like<br \/>\n\u2018%secure%\u2019;<\/p>\n<p>+\u2014\u2014\u2014\u2014\u2014\u2014+\u2014\u2014-+<\/p>\n<p>| Variable_name | Value |<\/p>\n<p>+\u2014\u2014\u2014\u2014\u2014\u2014+\u2014\u2014-+<\/p>\n<p>| secure_auth | ON |<\/p>\n<p>| secure_file_priv | |<\/p>\n<p>+\u2014\u2014\u2014\u2014\u2014\u2014+\u2014\u2014-+<\/p>\n<p>2 rows in set \uff080.00 sec\uff09<\/p>\n<p>\u5df2\u7ecf\u662f\u6211\u4eec\u8981\u7684\u7ed3\u679c<\/p>\n<p>\u4e0b\u9762\u6211\u4eec\u5f00\u59cb\u8fdb\u884c\u5bfc\u51fa<\/p>\n<p>\uff3broot@potato Desktop\uff3d# mysqldump -uroot -proot -S \/tmp\/mysql.sock<br \/>\n\u2013tab=\/data\/mysql\/mytest_3306\/data\/backup lala<\/p>\n<p>Warning\uff1a Using a password on the command line interface can be insecure.<\/p>\n<p>\u90a3\u4e48\u6211\u4eec\u5c31\u53ef\u4ee5\u770b\u5230\u6210\u529f\u4e86<\/p>\n<p>\u63a8\u8350\u66f4\u591a\u76f8\u5173\u5185\u5bb9 <a href=\"https:\/\/cn.raksmart.com\/blog\/server\/723.html\">\u5982\u4f55\u8fd0\u884c\u4e0e\u5173\u95edMySQL\u670d\u52a1\u5668\u3002<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4eca\u5929\u6709\u4e2a\u7f51\u53cb\u95ee\uff0c\u5728\u7528mysqldump\u5907\u4efd\u65f6\u5019\u9047\u52301290\u7684\u9519\u8bef\u3002\u672c\u6587Raksmart\u72ec\u7acb\u670d\u52a1\u5668\u5546\u5c31\u2026 <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[684,35],"class_list":["post-851","post","type-post","status-publish","format-standard","hentry","category-1","tag-mysql","tag-35"],"_links":{"self":[{"href":"https:\/\/cn.raksmart.com\/blog\/wp-json\/wp\/v2\/posts\/851","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/cn.raksmart.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/cn.raksmart.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/cn.raksmart.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/cn.raksmart.com\/blog\/wp-json\/wp\/v2\/comments?post=851"}],"version-history":[{"count":0,"href":"https:\/\/cn.raksmart.com\/blog\/wp-json\/wp\/v2\/posts\/851\/revisions"}],"wp:attachment":[{"href":"https:\/\/cn.raksmart.com\/blog\/wp-json\/wp\/v2\/media?parent=851"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cn.raksmart.com\/blog\/wp-json\/wp\/v2\/categories?post=851"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cn.raksmart.com\/blog\/wp-json\/wp\/v2\/tags?post=851"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}