{"id":3438,"date":"2012-09-08T11:17:00","date_gmt":"2012-09-08T03:17:00","guid":{"rendered":"http:\/\/jpuyy.com\/?p=3438"},"modified":"2013-08-29T15:48:33","modified_gmt":"2013-08-29T07:48:33","slug":"mysql-full-using","status":"publish","type":"post","link":"https:\/\/jpuyy.com\/?p=3438","title":{"rendered":"mysql\u6570\u636e\u5e93\u7a7a\u95f4\u7528\u6ee1\u65f6\uff0c\u5de7\u7528\u8f6f\u94fe\u63a5\u8f6c\u79fb"},"content":{"rendered":"<p>\u53c2\u8003\uff1a<a href=\"http:\/\/www.webhostingtalk.com\/showthread.php?t=1086919\">http:\/\/www.webhostingtalk.com\/showthread.php?t=1086919<\/a><\/p>\n<p>\u5bf9\u4e8e\u4e00\u4e9b\u505aSEO\u7684\u4eba\u6765\u8bf4\uff0c\/var\/lib\/mysql \u548c \/var\/www \u662f\u4e24\u4e2a\u5360\u7528\u7a7a\u95f4\u7684\u5927\u6237\uff0c\u4e0b\u9762\u4ee5\u6570\u636e\u5e93\u4e3a\u4f8b\uff0c\u5c06\/var\/lib\/mysql\u4e0b\u7684\u6570\u636e\u5e93\u79fb\u52a8\u5230\u8f83\u5927\u7684\/home\u4e0b\uff0c\u5e76\u4f7f\u7528\u8f6f\u94fe\u63a5\u5c06\/home\/mysql \u94fe\u63a5\u5230\/var\/lib\/mysql\uff0c\u5b9e\u73b0\u5145\u5206\u5229\u7528\u7a7a\u95f4\u7684\u76ee\u7684\u3002<\/p>\n<p>\u5728\u8fd9\u4e9b\u7f51\u7ad9\u90fd\u4e0d\u5728\u4f7f\u7528\u7684\u65f6\u5019\uff0c\u505c\u7528mysql\uff0capache<\/p>\n<pre>\/etc\/init.d\/mysqld stop\r\n\/etc\/init.d\/httpd stop<\/pre>\n<p>\u4f7f\u7528rsync\u5b8c\u6574\u7684\u5c06\u6570\u636e\u62f7\u8d1d\uff08-a archive mode\u5f52\u6863\u6a21\u5f0f -v verbos\u663e\u793a\u8be6\u7ec6\u00a0\uff09<\/p>\n<pre>rsync -av \/var\/lib\/mysql \/home\/<\/pre>\n<p>\u8fd9\u4e2a\u8fc7\u7a0b\u6839\u636e\u6570\u636e\u91cf\u7684\u4e0d\u540c\u65f6\u95f4\u4e0d\u540c\uff0c\u6570\u636e\u5f88\u5927\u7684\u8bdd\u5efa\u8bae\u4f7f\u7528screen<\/p>\n<p>\u63a5\u4e0b\u6765\u770b\u4e00\u4e0b\u5927\u5c0f\uff0c\u5982\u679c\u4ee5\u4e0a\u547d\u4ee4\u90fd\u5b8c\u5168\u6267\u884c\u5b8c\u7684\u8bdd\uff0c\u662f\u4e0d\u4f1a\u51fa\u73b0\u4ec0\u4e48\u95ee\u9898\u7684<\/p>\n<pre>du -sh \/var\/lib\/mysql\r\ndu -sh \/home\/mysql<\/pre>\n<p>\u5c06\u65e7\u7684\/var\/lib\/mysql\u79fb\u8d70\uff0c\u968f\u4fbf\u79fb\u5230\u4ec0\u4e48\u5730\u65b9\uff0c\u5b9e\u518d\u4e0d\u9700\u8981\u5220\u6389\u4e5f\u884c<\/p>\n<pre>mv \/var\/lib\/mysql \/var\/lib\/mysql-bak<\/pre>\n<p>\u521b\u5efa\u8f6f\u94fe\u63a5<\/p>\n<pre>ln -s \/home\/mysql \/var\/lib\/mysql<\/pre>\n<p>\u4e4b\u540e\u4e00\u5b9a\u8981\u518d\u6b21\u786e\u8ba4\u4e0a\u9762\u7684\u8f6f\u94fe\u63a5\u94fe\u63a5\u5230\u5bf9\u7684\u5730\u65b9\uff0c\u5982\u679c\u4e0d\u6b63\u786emysql\u4e00\u542f\u52a8\u5c31\u9ebb\u70e6\u4e86\u3002<\/p>\n<p>&nbsp;<\/p>\n<p>#######ubuntu\u7528\u6237\u6ce8\u610f begin#######<\/p>\n<p>\u5982\u679c\u4f7f\u7528ubuntu\u4e0bapt-get\u5b89\u88c5\u7684mysql\u7248\u672c\uff0c\u8fd8\u9700\u5982\u4e0b\u64cd\u4f5c<\/p>\n<pre>vim \/etc\/apparmor.d\/usr.sbin.mysqld<\/pre>\n<p>\u5c06\u5982\u4e0b\u4e24\u884c\u6ce8\u91ca<\/p>\n<pre>\/var\/lib\/mysql\/ r,\r\n\/var\/lib\/mysql\/** rwk,<\/pre>\n<p>\u53d8\u66f4\u4e3a\uff08\u53ef\u80fd\u662f\u56e0\u4e3aapparmor\u4e0d\u652f\u6301\u8f6f\u94fe\u63a5\uff09<\/p>\n<pre>\/home\/mysql\/ r,\r\n\/home\/mysql\/** rwk,<\/pre>\n<p>\u91cd\u542fapparmor<\/p>\n<pre>\/etc\/init.d\/apparmor restart<\/pre>\n<p>#######ubuntu\u7528\u6237\u6ce8\u610f end#######<\/p>\n<p>&nbsp;<\/p>\n<p>\u4e4b\u540e\u542f\u52a8mysql\uff0capache<\/p>\n<pre>\/etc\/init.d\/mysqld start\r\n\/etc\/init.d\/httpd start<\/pre>\n<p>\u8fd9\u6837\u4ee5\u540e\u6240\u6709\u7684mysql\u6570\u636e\u7684\u4f4d\u7f6e\u5c31\u5728\/home\/mysql\u91cc\u4e86\u3002<\/p>\n<h1>\u53e6\u4e00\u79cd\u89e3\u51b3\u65b9\u6848\uff1a\u4e0d\u7528\u8f6f\u94fe\u63a5\u800c\u76f4\u63a5\u5c06\u6570\u636e\u5e93\u8f6c\u79fb\u5230\u76ee\u5f55\/mnt\/sx_disk<\/h1>\n<pre>rsync -av \/var\/lib\/mysql \/mnt\/sx_disk\/<\/pre>\n<p>\u4e4b\u540e\u5728\/etc\/my.cnf\u4e2d\uff0c\u5c06[mysqld]\u4e2d\u7684\u5982\u4e0b\u53c2\u6570\u6539\u4e3a<\/p>\n<pre>[mysqld]\r\ndatadir=\/mnt\/sx_disk\/mysql\r\nsocket=\/mnt\/sx_disk\/mysql\/mysql.sock<\/pre>\n<p>\u53ea\u8fd9\u6837\u8fd8\u4e0d\u884c\uff0c\u4f1a\u51fa\u73b0<\/p>\n<pre>ERROR 2002 (HY000): Can't connect to local MySQL server through socket '\/var\/lib\/mysql\/mysql.sock' (2)<\/pre>\n<p>\u53e6\u5916\u9700\u6dfb\u52a0<\/p>\n<pre>[client]\r\nport=3306\r\nsocket=\/mnt\/sx_disk\/mysql\/mysql.sock<\/pre>\n<p>\u8fd9\u6837\u6570\u636e\u5e93\u5c31\u5b58\u4e3a\u4e86\u65b0\u7684\u4f4d\u7f6e\/mnt\/sx_disk\u76ee\u5f55\u4e2d\u3002<\/p>\n<p>\u5982\u679c\u540c\u662fubuntu\u4e0bmysql\u7684\u8bdd\uff0c\u4e5f\u9700\u8981\u6309\u4e0a\u9762\u7684\u65b9\u5f0f\u4fee\u6539<code>\/etc\/apparmor.d\/usr.sbin.mysqld<\/code><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u53c2\u8003\uff1ahttp:\/\/www.webhostingtalk.com\/showthread.php?t=1086919 \u5bf9\u4e8e\u4e00\u4e9b\u505aSEO\u7684\u4eba\u6765\u8bf4\uff0c\/var\/lib\/mysql \u548c \/var\/www \u662f\u4e24\u4e2a\u5360\u7528\u7a7a\u95f4\u7684\u5927\u6237\uff0c\u4e0b\u9762\u4ee5\u6570\u636e\u5e93\u4e3a\u4f8b\uff0c\u5c06\/var\/lib\/mysql\u4e0b\u7684\u6570\u636e\u5e93\u79fb\u52a8\u5230\u8f83\u5927\u7684\/home\u4e0b\uff0c\u5e76\u4f7f\u7528\u8f6f\u94fe\u63a5\u5c06\/home\/mysql \u94fe\u63a5\u5230\/var\/lib\/mysql\uff0c\u5b9e\u73b0\u5145\u5206\u5229\u7528\u7a7a\u95f4\u7684\u76ee\u7684\u3002 \u5728\u8fd9\u4e9b\u7f51\u7ad9\u90fd\u4e0d\u5728\u4f7f\u7528\u7684\u65f6\u5019\uff0c\u505c\u7528mysql\uff0capache \/etc\/init.d\/mysqld stop \/etc\/init.d\/httpd stop \u4f7f\u7528rsync\u5b8c\u6574\u7684\u5c06\u6570\u636e\u62f7\u8d1d\uff08-a archive mode\u5f52\u6863\u6a21\u5f0f -v verbos\u663e\u793a\u8be6\u7ec6\u00a0\uff09 rsync -av \/var\/lib\/mysql \/home\/ \u8fd9\u4e2a\u8fc7\u7a0b\u6839\u636e\u6570\u636e\u91cf\u7684\u4e0d\u540c\u65f6\u95f4\u4e0d\u540c\uff0c\u6570\u636e\u5f88\u5927\u7684\u8bdd\u5efa\u8bae\u4f7f\u7528screen \u63a5\u4e0b\u6765\u770b\u4e00\u4e0b\u5927\u5c0f\uff0c\u5982\u679c\u4ee5\u4e0a\u547d\u4ee4\u90fd\u5b8c\u5168\u6267\u884c\u5b8c\u7684\u8bdd\uff0c\u662f\u4e0d\u4f1a\u51fa\u73b0\u4ec0\u4e48\u95ee\u9898\u7684 du -sh \/var\/lib\/mysql du -sh \/home\/mysql \u5c06\u65e7\u7684\/var\/lib\/mysql\u79fb\u8d70\uff0c\u968f\u4fbf\u79fb\u5230\u4ec0\u4e48\u5730\u65b9\uff0c\u5b9e\u518d\u4e0d\u9700\u8981\u5220\u6389\u4e5f\u884c mv \/var\/lib\/mysql \/var\/lib\/mysql-bak \u521b\u5efa\u8f6f\u94fe\u63a5 ln -s \/home\/mysql \/var\/lib\/mysql \u4e4b\u540e\u4e00\u5b9a\u8981\u518d\u6b21\u786e\u8ba4\u4e0a\u9762\u7684\u8f6f\u94fe\u63a5\u94fe\u63a5\u5230\u5bf9\u7684\u5730\u65b9\uff0c\u5982\u679c\u4e0d\u6b63\u786emysql\u4e00\u542f\u52a8\u5c31\u9ebb\u70e6\u4e86\u3002 &nbsp; #######ubuntu\u7528\u6237\u6ce8\u610f begin####### \u5982\u679c\u4f7f\u7528ubuntu\u4e0bapt-get\u5b89\u88c5\u7684mysql\u7248\u672c\uff0c\u8fd8\u9700\u5982\u4e0b\u64cd\u4f5c vim \/etc\/apparmor.d\/usr.sbin.mysqld \u5c06\u5982\u4e0b\u4e24\u884c\u6ce8\u91ca \/var\/lib\/mysql\/ r, \/var\/lib\/mysql\/** rwk, \u53d8\u66f4\u4e3a\uff08\u53ef\u80fd\u662f\u56e0\u4e3aapparmor\u4e0d\u652f\u6301\u8f6f\u94fe\u63a5\uff09 \/home\/mysql\/ r, \/home\/mysql\/** rwk, \u91cd\u542fapparmor [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8,65],"tags":[99,100,23],"class_list":["post-3438","post","type-post","status-publish","format-standard","hentry","category-linux","category-mysql","tag-linux-tools","tag-sa","tag-summary"],"_links":{"self":[{"href":"https:\/\/jpuyy.com\/index.php?rest_route=\/wp\/v2\/posts\/3438","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jpuyy.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jpuyy.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jpuyy.com\/index.php?rest_route=\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/jpuyy.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3438"}],"version-history":[{"count":16,"href":"https:\/\/jpuyy.com\/index.php?rest_route=\/wp\/v2\/posts\/3438\/revisions"}],"predecessor-version":[{"id":5548,"href":"https:\/\/jpuyy.com\/index.php?rest_route=\/wp\/v2\/posts\/3438\/revisions\/5548"}],"wp:attachment":[{"href":"https:\/\/jpuyy.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3438"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jpuyy.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3438"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jpuyy.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3438"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}