{"id":683,"date":"2016-03-17T00:06:24","date_gmt":"2016-03-16T16:06:24","guid":{"rendered":"http:\/\/web.jofar.cn\/?p=683"},"modified":"2016-04-13T02:55:25","modified_gmt":"2016-04-12T18:55:25","slug":"mysql%e7%a7%bb%e5%8a%a8%e7%9b%ae%e5%bd%95","status":"publish","type":"post","link":"https:\/\/web.jofar.cn\/?p=683","title":{"rendered":"mysql\u79fb\u52a8\u76ee\u5f55"},"content":{"rendered":"<p>\n\t\u7531\u4e8eMySQL\u7684\u6570\u636e\u5e93\u592a\u5927\uff0c\u9ed8\u8ba4\u5b89\u88c5\u7684\/var\u76d8\u5df2\u7ecf\u518d\u4e5f\u65e0\u6cd5\u5bb9\u7eb3\u65b0\u589e\u52a0\u7684\u6570\u636e\uff0c\u6ca1\u6709\u529e\u6cd5\uff0c\u53ea\u80fd\u60f3\u529e\u6cd5\u8f6c\u79fb\u6570\u636e\u7684\u76ee\u5f55\u3002<br \/>\n\tMySql\u88c5\u5728\/usr\/local\/mysql\u4e0b\uff0c\u8981\u628aMySQL\u7684data\u76ee\u5f55\u4ece\/usr\/local\/mysql\u8f6c\u79fb\u5230\/home\/data\u76ee\u5f55\u7684\u5177\u4f53\u64cd\u4f5c\uff1a\n<\/p>\n<p>\n\t1\u3001\u9996\u5148\u6211\u4eec\u9700\u8981\u5173\u95edMySQL\uff0c\u547d\u4ee4\u5982\u4e0b(\u4efb\u9009\u4e00\u79cd\u5408\u9002\u81ea\u5df2\u73af\u5883\u7684)\uff1a<br \/>\n\t&nbsp; &nbsp;service mysqld stop<br \/>\n\t&nbsp; &nbsp;\/usr\/local\/mysql\/bin\/mysqld stop<br \/>\n\t&nbsp; &nbsp;\/etc\/init.d\/mysqld\u3000stop<br \/>\n\t&nbsp; &nbsp;<br \/>\n\t2\u3001\u7136\u540e\u662f\u8f6c\u79fb\u6570\u636e\uff0c\u4e3a\u4e86\u5b89\u5168\u671f\u95f4\uff0c\u6211\u4eec\u91c7\u7528\u590d\u5236\u547d\u4ee4cp\uff0c\u5148\u627e\u5230mysql\u7684\u539f\u76ee\u5f55<br \/>\n\t&nbsp; &nbsp;cd \/usr\/local\/mysql<br \/>\n\t&nbsp; &nbsp;ls<br \/>\n\t&nbsp; &nbsp;\u8fd0\u884c\u8fd9\u4e2a\u547d\u4ee4\u4e4b\u540e\u5c31\u4f1a\u770b\u5230mysql\u7684\u76ee\u5f55\u4e86\uff0c\u7136\u540e\u6267\u884ccp\u547d\u4ee4<br \/>\n\t&nbsp; &nbsp;cp -a \/usr\/local\/mysql \/home\/ &nbsp; #\u8fd9\u6837\u5c31\u628a\u6570\u636e\u5e93\u590d\u5236\u5230\/home\/\u4e0b\u9762\u53bb\u4e86<br \/>\n\t&nbsp; &nbsp;\u6ce8\u610f\uff1a\uff08-a\u8fd9\u4e2a\u53c2\u6570\u4e00\u5b9a\u8981\u5e26\u7740\uff0c\u5426\u5219\u590d\u5236\u8fc7\u53bb\u7684\u6743\u9650\u5c31\u4e0d\u5bf9\u4e86\u3002\uff09\n<\/p>\n<p>\n\t3\u3001\u7136\u540e\u6211\u4eec\u4fee\u6539\u914d\u7f6e\u6587\u4ef6\uff0c\u4e00\u5171\u6709\u4e09\u4e2a\uff0c\u4e0b\u9762\u6211\u4e00\u4e00\u8bf4\u660e\uff1a<br \/>\n\t&nbsp;&nbsp; &nbsp;\u7b2c\u4e00\u4e2a\u6587\u4ef6\uff1a\u4fee\u6539\u4e4b\u524d\u5148\u5907\u4efdcp &nbsp;\/etc\/my.cnf &nbsp; &nbsp;\/etc\/my.cnfbak<br \/>\n\t&nbsp; &nbsp; &nbsp; vi \/etc\/my.cnf<br \/>\n\t&nbsp; &nbsp; &nbsp; \u6253\u5f00\u4e4b\u540e\u4fee\u6539datadir\u7684\u76ee\u5f55\u4e3a\/home\/data<br \/>\n\t&nbsp; &nbsp; &nbsp; \u628asocket\u6539\u6210\/home\/data\/mysql.sock &nbsp;#\u4e3a\u4e86\u5b89\u5168\u8d77\u89c1\uff0c\u4f60\u53ef\u4ee5\u628a\u539f\u6765\u7684\u6ce8\u91ca\u6389\uff0c\u7136\u540e\u91cd\u65b0\u52a0\u5165\u4e00\u884c\uff0c\u6539\u6210\u73b0\u5728\u7684\u76ee\u5f55\u3002<br \/>\n\t&nbsp;&nbsp; &nbsp; &nbsp;\u5982\u679c\u662f\u7f16\u8bd1\u5b89\u88c5\u7684\uff0c \u6709\u6307\u5b9a\u6587\u4ef6\u5939\uff0c \u4e0b\u9762\u7684\u4e24\u4e2a\u6587\u4ef6\u5c31\u4e0d\u9700\u8981\u6539\uff0c\u53ea\u9700\u6539my.cnf\u5373\u53ef,\u6ce8\u610f\uff0cdatadir\u5c31\u662fmysql\u5185\u7684data\u76ee\u5f55<br \/>\n\t&nbsp;&nbsp; &nbsp;================================================================================<br \/>\n\t&nbsp; &nbsp; \u4fee\u6539\u7b2c\u4e8c\u4e2a\u6587\u4ef6\uff1a\u4fee\u6539\u4e4b\u524d\u5148\u5907\u4efd cp \/etc\/init.d\/mysqld &nbsp; &nbsp;\/etc\/init.d\/mysqld.bak<br \/>\n\t&nbsp; &nbsp; &nbsp; vi \/etc\/init.d\/mysqld<br \/>\n\t&nbsp; &nbsp; &nbsp; \u6ce8\u610f\uff1a\u51c6\u786e\u7684\u4f4d\u7f6e\u662f\/etc\/rc.d\/init.d\/mysqld\uff0c\u7531\u4e8e\u8fd9\u91cc\u8fd9\u91cc\u6709\u4e00\u4e2a\/etc\/init.d\u5230\/etc\/rc.d\/init.d\u7684\u6620\u5c04\uff0c\u6240\u4ee5\u7528\u4e0a\u9762\u7684\u547d\u4ee4\u5373\u53ef\uff0c\u4e5f\u7b80\u5355\u3002<br \/>\n\t&nbsp; &nbsp; &nbsp; \u628a\u5176\u4e2ddatadir=\/usr\/local\/mysql\/data \u4e00\u884c\u4e2d\uff0c\u7b49\u53f7\u53f3\u8fb9\u7684\u8def\u5f84\u6539\u6210\u4f60\u73b0\u5728\u7684\u5b9e\u9645\u5b58\u653e\u8def\u5f84\uff1a\/home\/data<br \/>\n\t&nbsp;&nbsp; &nbsp;=================================================================================<br \/>\n\t&nbsp; &nbsp; \u4fee\u6539\u7b2c\u4e09\u4e2a\u6587\u4ef6\uff1a\u4fee\u6539\u4e4b\u524d\u5148\u5907\u4efd cp \/usr\/bin\/mysqld_safe &nbsp; &nbsp;\/usr\/bin\/mysqld_safe.bak<br \/>\n\t&nbsp; &nbsp; &nbsp; vi \/usr\/bin\/mysqld_safe<br \/>\n\t&nbsp; &nbsp; &nbsp; \u8fd9\u91cc\u4e5f\u662f\u4fee\u6539datadir\u7684\u76ee\u5f55\u4e3a\/home\/mysql\n<\/p>\n<p>\n\t4\u3001\u4e0b\u9762\u9700\u8981\u5efa\u7acb\u4e00\u4e2amysql.sock\u7684\u94fe\u63a5\uff1a<br \/>\n\t&nbsp; &nbsp;ln -s \/home\/mysql\/mysql.sock &nbsp; &nbsp;\/usr\/local\/mysql\/mysql.sock<br \/>\n\t&nbsp; &nbsp; \u81f3\u6b64\u6240\u6709\u7684\u4fee\u6539\u90fd\u5b8c\u6210\u4e86\uff0c\u4e0b\u9762\u542f\u52a8mysql<br \/>\n\t&nbsp; &nbsp; service mysqld start<br \/>\n\t&nbsp; &nbsp; \u6216\u8005\u91cd\u542flinux<br \/>\n\t&nbsp; &nbsp; reboot<br \/>\n\t&nbsp; &nbsp; \u5982\u679c\u80fd\u6b63\u5e38\u542f\u52a8\uff0c\u8bf4\u660e\u4fee\u6539\u6210\u529f\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u7531\u4e8eMySQL\u7684\u6570\u636e\u5e93\u592a\u5927\uff0c\u9ed8\u8ba4\u5b89\u88c5\u7684\/var\u76d8\u5df2\u7ecf\u518d\u4e5f\u65e0\u6cd5\u5bb9\u7eb3\u65b0\u589e\u52a0\u7684\u6570\u636e\uff0c\u6ca1\u6709\u529e\u6cd5\uff0c\u53ea\u80fd\u60f3\u529e\u6cd5\u8f6c\u79fb\u6570\u636e\u7684\u76ee\u2026 <span class=\"read-more\"><a href=\"https:\/\/web.jofar.cn\/?p=683\">Read More &raquo;<\/a><\/span><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[10,5],"tags":[],"class_list":["post-683","post","type-post","status-publish","format-standard","hentry","category-mysql","category-practice-readme"],"_links":{"self":[{"href":"https:\/\/web.jofar.cn\/index.php?rest_route=\/wp\/v2\/posts\/683","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/web.jofar.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/web.jofar.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/web.jofar.cn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/web.jofar.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=683"}],"version-history":[{"count":0,"href":"https:\/\/web.jofar.cn\/index.php?rest_route=\/wp\/v2\/posts\/683\/revisions"}],"wp:attachment":[{"href":"https:\/\/web.jofar.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=683"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/web.jofar.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=683"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/web.jofar.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=683"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}