{"id":6389,"date":"2024-11-14T10:55:04","date_gmt":"2024-11-14T02:55:04","guid":{"rendered":"https:\/\/fwq.ai\/blog\/6389\/"},"modified":"2024-11-14T10:55:04","modified_gmt":"2024-11-14T02:55:04","slug":"mysql%e6%95%b0%e6%8d%ae%e5%ba%93%e4%bf%9d%e5%ad%98%e8%b7%af%e5%be%84","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/6389\/","title":{"rendered":"mysql\u6570\u636e\u5e93\u4fdd\u5b58\u8def\u5f84"},"content":{"rendered":"<blockquote><p>\n  mysql \u6570\u636e\u548c\u914d\u7f6e\u6587\u4ef6\u5b58\u50a8\u5728\u6587\u4ef6\u7cfb\u7edf\u4e2d\u7684\u7279\u5b9a\u8def\u5f84\u4e2d\uff0c\u9ed8\u8ba4\u4f4d\u7f6e\u5982\u4e0b\uff1alinux\/unix\uff1a\/var\/lib\/mysqlwindows\uff1ac:programdatamysqlmysql server x.ydata\n<\/p><\/blockquote>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/202408\/01\/2024080106313364159.jpg\" class=\"aligncenter\" title=\"mysql\u6570\u636e\u5e93\u4fdd\u5b58\u8def\u5f84\u63d2\u56fe\" alt=\"mysql\u6570\u636e\u5e93\u4fdd\u5b58\u8def\u5f84\u63d2\u56fe\" \/><\/p>\n<p><strong>MySQL \u6570\u636e\u5e93\u4fdd\u5b58\u8def\u5f84<\/strong><\/p>\n<p><strong>MySQL \u6570\u636e\u5e93\u6587\u4ef6\u5b58\u50a8\u5728\u54ea\uff1f<\/strong><\/p>\n<p>MySQL \u6570\u636e\u5e93\u6570\u636e\u548c\u914d\u7f6e\u6587\u4ef6\u5b58\u50a8\u5728\u6587\u4ef6\u7cfb\u7edf\u4e2d\u7684\u7279\u5b9a\u8def\u5f84\u4e2d\u3002\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0cMySQL \u7684\u6570\u636e\u76ee\u5f55\u5728\u4ee5\u4e0b\u4f4d\u7f6e\uff1a<\/p>\n<ul>\n<li>Linux\/Unix\uff1a\/var\/lib\/ <\/li>\n<li>Windows\uff1aC:ProgramDataMySQLMySQL Server X.YData<\/li>\n<\/ul>\n<p><strong>\u5176\u4ed6\u53ef\u80fd\u7684\u6570\u636e\u76ee\u5f55\u8def\u5f84\uff1a<\/strong><\/p>\n<p>\u5728\u67d0\u4e9b\u60c5\u51b5\u4e0b\uff0c\u6570\u636e\u76ee\u5f55\u8def\u5f84\u53ef\u80fd\u4e0e\u9ed8\u8ba4\u8bbe\u7f6e\u4e0d\u540c\u3002\u4ee5\u4e0b\u662f\u53ef\u80fd\u7684\u60c5\u51b5\uff1a<\/p>\n<ul>\n<li> <strong>\u81ea\u5b9a\u4e49\u5b89\u88c5\uff1a<\/strong>\u5728\u5b89\u88c5\u671f\u95f4\uff0c\u53ef\u4ee5\u6307\u5b9a\u81ea\u5b9a\u4e49\u6570\u636e\u76ee\u5f55\u4f4d\u7f6e\u3002<\/li>\n<li> <strong>\u73af\u5883\u53d8\u91cf\uff1a<\/strong>MYSQL_DATADIR \u73af\u5883\u53d8\u91cf\u53ef\u4ee5\u8986\u76d6\u9ed8\u8ba4\u6570\u636e\u76ee\u5f55\u8def\u5f84\u3002<\/li>\n<li> <strong>\u914d\u7f6e\u6587\u4ef6\uff1a<\/strong>my.cnf \u6216 my.ini \u914d\u7f6e\u6587\u4ef6\u4e2d\u53ef\u4ee5\u8bbe\u7f6e datadir \u9009\u9879\u3002<\/li>\n<\/ul>\n<p><strong>\u67e5\u627e\u5f53\u524d\u6570\u636e\u76ee\u5f55\u8def\u5f84\uff1a<\/strong><\/p>\n<p>\u8981\u627e\u5230\u5f53\u524d\u4f7f\u7528\u7684 MySQL \u6570\u636e\u76ee\u5f55\u8def\u5f84\uff0c\u8bf7\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<pre>SELECT @@datadir;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>\u66f4\u6539\u6570\u636e\u76ee\u5f55\u8def\u5f84\uff1a<\/strong><\/p>\n<p>\u5982\u679c\u9700\u8981\u66f4\u6539\u6570\u636e\u76ee\u5f55\u4f4d\u7f6e\uff0c\u53ef\u4ee5\u4f7f\u7528 datadir \u9009\u9879\u3002\u5728 my.cnf \u6216 my.ini \u914d\u7f6e\u6587\u4ef6\u4e2d\u6dfb\u52a0\u6216\u66f4\u65b0\u4ee5\u4e0b\u884c\uff1a<\/p>\n<pre>[mysqld]\ndatadir=\/new\/data\/directory\/path<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u4e4b\u540e\uff0c\u5fc5\u987b\u91cd\u65b0\u542f\u52a8 MySQL \u670d\u52a1\u4ee5\u5e94\u7528\u66f4\u6539\u3002<\/p>\n<p><strong>\u91cd\u8981\u63d0\u793a\uff1a<\/strong><\/p>\n<ul>\n<li>\u66f4\u6539\u6570\u636e\u76ee\u5f55\u8def\u5f84\u524d\uff0c\u6700\u597d\u5148\u5907\u4efd\u6240\u6709\u6570\u636e\u3002<\/li>\n<li>\u5982\u679c\u5c06\u6570\u636e\u76ee\u5f55\u79fb\u52a8\u5230\u5916\u90e8\u9a71\u52a8\u5668\u6216\u7f51\u7edc\u5171\u4eab\uff0c\u8bf7\u786e\u4fdd\u5b83\u4eec\u59cb\u7ec8\u53ef\u7528\u3002<\/li>\n<\/ul>\n<p>\u4ee5\u4e0a\u5c31\u662f\u6570\u636e\u5e93\u4fdd\u5b58\u8def\u5f84\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>mysql \u6570\u636e\u548c\u914d\u7f6e\u6587\u4ef6\u5b58\u50a8\u5728\u6587\u4ef6\u7cfb\u7edf\u4e2d\u7684\u7279\u5b9a\u8def\u5f84\u4e2d\uff0c\u9ed8\u8ba4\u4f4d\u7f6e\u5982\u4e0b\uff1alinux\/unix\uff1a\/var\/lib\/mysqlwindows\uff1ac:programdatamysqlmysql server x.ydata MySQL \u6570\u636e\u5e93\u4fdd\u5b58\u8def\u5f84 MySQL \u6570\u636e\u5e93\u6587\u4ef6\u5b58\u50a8\u5728\u54ea\uff1f MySQL \u6570\u636e\u5e93\u6570\u636e\u548c\u914d\u7f6e\u6587\u4ef6\u5b58\u50a8\u5728\u6587\u4ef6\u7cfb\u7edf\u4e2d\u7684\u7279\u5b9a\u8def\u5f84\u4e2d\u3002\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0cMySQL \u7684\u6570\u636e\u76ee\u5f55\u5728\u4ee5\u4e0b\u4f4d\u7f6e\uff1a Linux\/Unix\uff1a\/var\/lib\/ Windows\uff1aC:ProgramDataMySQLMySQL Server X.YData \u5176\u4ed6\u53ef\u80fd\u7684\u6570\u636e\u76ee\u5f55\u8def\u5f84\uff1a \u5728\u67d0\u4e9b\u60c5\u51b5\u4e0b\uff0c\u6570\u636e\u76ee\u5f55\u8def\u5f84\u53ef\u80fd\u4e0e\u9ed8\u8ba4\u8bbe\u7f6e\u4e0d\u540c\u3002\u4ee5\u4e0b\u662f\u53ef\u80fd\u7684\u60c5\u51b5\uff1a \u81ea\u5b9a\u4e49\u5b89\u88c5\uff1a\u5728\u5b89\u88c5\u671f\u95f4\uff0c\u53ef\u4ee5\u6307\u5b9a\u81ea\u5b9a\u4e49\u6570\u636e\u76ee\u5f55\u4f4d\u7f6e\u3002 \u73af\u5883\u53d8\u91cf\uff1aMYSQL_DATADIR \u73af\u5883\u53d8\u91cf\u53ef\u4ee5\u8986\u76d6\u9ed8\u8ba4\u6570\u636e\u76ee\u5f55\u8def\u5f84\u3002 \u914d\u7f6e\u6587\u4ef6\uff1amy.cnf \u6216 my.ini \u914d\u7f6e\u6587\u4ef6\u4e2d\u53ef\u4ee5\u8bbe\u7f6e datadir \u9009\u9879\u3002 \u67e5\u627e\u5f53\u524d\u6570\u636e\u76ee\u5f55\u8def\u5f84\uff1a \u8981\u627e\u5230\u5f53\u524d\u4f7f\u7528\u7684 MySQL \u6570\u636e\u76ee\u5f55\u8def\u5f84\uff0c\u8bf7\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\uff1a SELECT @@datadir; \u767b\u5f55\u540e\u590d\u5236 \u66f4\u6539\u6570\u636e\u76ee\u5f55\u8def\u5f84\uff1a \u5982\u679c\u9700\u8981\u66f4\u6539\u6570\u636e\u76ee\u5f55\u4f4d\u7f6e\uff0c\u53ef\u4ee5\u4f7f\u7528 datadir \u9009\u9879\u3002\u5728 my.cnf \u6216 my.ini \u914d\u7f6e\u6587\u4ef6\u4e2d\u6dfb\u52a0\u6216\u66f4\u65b0\u4ee5\u4e0b\u884c\uff1a [mysqld] datadir=\/new\/data\/directory\/path \u767b\u5f55\u540e\u590d\u5236 \u4e4b\u540e\uff0c\u5fc5\u987b\u91cd\u65b0\u542f\u52a8 MySQL \u670d\u52a1\u4ee5\u5e94\u7528\u66f4\u6539\u3002 \u91cd\u8981\u63d0\u793a\uff1a \u66f4\u6539\u6570\u636e\u76ee\u5f55\u8def\u5f84\u524d\uff0c\u6700\u597d\u5148\u5907\u4efd\u6240\u6709\u6570\u636e\u3002 \u5982\u679c\u5c06\u6570\u636e\u76ee\u5f55\u79fb\u52a8\u5230\u5916\u90e8\u9a71\u52a8\u5668\u6216\u7f51\u7edc\u5171\u4eab\uff0c\u8bf7\u786e\u4fdd\u5b83\u4eec\u59cb\u7ec8\u53ef\u7528\u3002 \u4ee5\u4e0a\u5c31\u662f\u6570\u636e\u5e93\u4fdd\u5b58\u8def\u5f84\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},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-6389","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/6389","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=6389"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/6389\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=6389"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=6389"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=6389"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}