{"id":32,"date":"2017-10-30T23:32:18","date_gmt":"2017-10-30T15:32:18","guid":{"rendered":"http:\/\/kkong.net\/?p=32"},"modified":"2017-11-07T09:47:13","modified_gmt":"2017-11-07T01:47:13","slug":"mysql-%e4%ba%a7%e7%94%9f%e5%a4%a7%e6%97%a5%e5%bf%97%e6%96%87%e4%bb%b6%e5%8d%a0%e7%94%a8%e7%a9%ba%e9%97%b4%ef%bc%81","status":"publish","type":"post","link":"https:\/\/kkong.net\/?p=32","title":{"rendered":"mysql \u4ea7\u751f\u5927\u65e5\u5fd7\u6587\u4ef6\u5360\u7528\u7a7a\u95f4\uff01"},"content":{"rendered":"<p>\u88c5\u65b0\u7248\u672c\u7684mysql 5.5\u65f6\uff0c\u9047\u5230\u4e86\u4e2a\u95ee\u9898\u65e0\u6cd5\u5b89\u88c5\uff0c\u63d0\u793a\u7cfb\u7edf\u7a7a\u95f4\u4e0d\u8db3\u3002\u4e8e\u662f\u6211\u5c31\u56f0\u60d1\u4e86\uff0c10G\u7684\u786c\u76d8\u4e0d\u4f1a\u56e0\u4e3a\u6302\u4e2awordpress\u5c31\u6ee1\u4e86\u5427\uff1f\uff01\u901a\u8fc7df -lh\u67e5\u770b\u4e86\u4e0b\u786c\u76d8\u7684\u4f7f\u7528\u60c5\u51b5\uff0c\u987f\u65f6\u6211\u60ca\u5446\u4e86\uff0c20G\u7684\u786c\u76d8\u7adf\u7136\u4f7f\u7528\u7387100%\uff0c\u7a76\u7adf\u662f\u4ec0\u4e48\u5360\u7528\u4e86\u8fd9\u4e48\u5927\u7684\u7a7a\u95f4\u5462\uff1f<\/p>\n<p>\u4f7f\u7528du -sh \/root\u67e5\u770b\u4e86\u4e0b\u5404\u4e2a\u6587\u4ef6\u5939\u7684\u4f7f\u7528\uff0c\u53d1\u73b0\u6709\u4e2a\u6587\u4ef6\u5939\u7adf\u7136\u5360\u7528\u4e868G\u7684\u5927\u5c0f\uff0c\u4e0d\u65ad\u7684\u6df1\u5165\u53d1\u73b0\u4e86\u6839\u6e90\/var\/lib\/mysql\u4e0b\u7684N\u4e2amysql-bin.*\u6587\u4ef6\uff0c\u6bcf\u4e2a\u6587\u4ef6\u4ece\u51e0k\u5230\u51e0G\u4e0d\u7b49\uff0c\u4e0a\u7f51\u67e5\u4e86\u4e0b\u4e86\u89e3\u5230\uff0c\u539f\u6765\u662fmysql\u7684\u64cd\u4f5c\u65e5\u5fd7\uff0c\u4f8b\u5982UPDATE\u4e00\u4e2a\u8868\uff0c\u6216\u8005DELETE\u4e00\u4e9b\u6570\u636e\uff0c\u5373\u4f7f\u8be5\u8bed\u53e5\u6ca1\u6709\u5339\u914d\u7684\u6570\u636e\uff0c\u8fd9\u4e2a\u547d\u4ee4\u4e5f\u4f1a\u5b58\u50a8\u5230\u65e5\u5fd7\u6587\u4ef6\u4e2d\uff0c\u8fd8\u5305\u62ec\u6bcf\u4e2a\u8bed\u53e5\u6267\u884c\u7684\u65f6\u95f4\uff0c\u4e5f\u4f1a\u8bb0\u5f55\u8fdb\u53bb\u7684\u3002<\/p>\n<p>\u56e0\u6b64\u5b9a\u4f4d\u95ee\u9898\uff1amysql\u7684\u64cd\u4f5c\u65e5\u5fd7\u8fc7\u5927\uff082\u4e2a\u6708\uff09\u5df2\u7ecf8\u4e2aG\u4e86\uff0c\u5bfc\u81f4\u5360\u636e\u786c\u76d8\u7a7a\u95f4\uff0c\u4f7f\u6570\u636e\u5e93\u65e0\u6cd5\u6b63\u5e38\u4f7f\u7528\u5bfc\u81f4\u5b95\u673a\u3002<\/p>\n<p>\u95ee\u9898\u89e3\u51b3<\/p>\n<p>1\u3001\u8fdb\u5165mysql\uff1a<br \/>\n<code class=\"prettyprint\" >mysql -u root -p<\/code><\/p>\n<p>2\u3001\u8f93\u5165\u6e05\u9664\u65e5\u5fd7\u6587\u4ef6\u547d\u4ee4\uff1areset master;<\/p>\n<p>\u53ef\u80fd\u4f1a\u9047\u5230\u95ee\u9898\uff1aERROR 1186 (HY000): Binlog closed, cannot RESET MASTER\uff0c\u539f\u56e0\u662f\u5df2\u7ecf\u5173\u95ed\u4e86\u65e5\u5fd7\u7cfb\u7edf\uff0c\u6240\u4ee5\u65e0\u6cd5\u6e05\u9664\uff0c\u5177\u4f53\u770b\u4e0b\u6587\u95ee\u9898\u89e3\u7b54\u3002<\/p>\n<p>\u95ee\u9898\u907f\u514d<\/p>\n<p>mysql\u6570\u636e\u6587\u4ef6\u624d\u51e0\u767e\u5146\uff0c\u800c\u65e5\u5fd7\u6587\u4ef6\u8fbe\u5230\u5341\u51e0G\uff0c\u8fd9\u7a76\u7adf\u662f\u6709\u4ec0\u4e48\u4f5c\u7528\u5462\uff1f\u8fd9\u4e3b\u8981\u6709\u4e24\u4e2a\u4f5c\u7528\uff1a<\/p>\n<p>\uff081\uff09\u6570\u636e\u6062\u590d<\/p>\n<p>\u5982\u679c\u4f60\u7684\u6570\u636e\u5e93\u51fa\u95ee\u9898\u4e86\uff0c\u800c\u4f60\u4e4b\u524d\u6709\u8fc7\u5907\u4efd\uff0c\u90a3\u4e48\u53ef\u4ee5\u770b\u65e5\u5fd7\u6587\u4ef6\uff0c\u627e\u51fa\u662f\u54ea\u4e2a\u547d\u4ee4\u5bfc\u81f4\u4f60\u7684\u6570\u636e\u5e93\u51fa\u95ee\u9898\u4e86\uff0c\u60f3\u529e\u6cd5\u633d\u56de\u635f\u5931\u3002<\/p>\n<p>\uff082\uff09\u4e3b\u4ece\u670d\u52a1\u5668\u4e4b\u95f4\u540c\u6b65\u6570\u636e<\/p>\n<p>\u4e3b\u670d\u52a1\u5668\u4e0a\u6240\u6709\u7684\u64cd\u4f5c\u90fd\u5728\u8bb0\u5f55\u65e5\u5fd7\u4e2d\uff0c\u4ece\u670d\u52a1\u5668\u53ef\u4ee5\u6839\u636e\u8be5\u65e5\u5fd7\u6765\u8fdb\u884c\uff0c\u4ee5\u786e\u4fdd\u4e24\u4e2a\u540c\u6b65\u3002<\/p>\n<p>\u4f46\u662f\u5bf9\u4e8e\u6211\u8fd9\u79cd\u5c0f\u578b\u670d\u52a1\u5668\u5176\u5b9e\u5e76\u4e0d\u9700\u8981\u8fd9\u6837\u7684\u65e5\u5fd7\u7cfb\u7edf\uff0c\u53cd\u800c\u4f1a\u5f71\u54cd\u6211\u6574\u4e2a\u7cfb\u7edf\u7684\u8fd0\u884c\u3002\u6240\u4ee5\u53ef\u4ee5\u8fdb\u884c\u53d6\u6d88\uff0c\u65b9\u6cd5\u5982\u4e0b\uff1a<\/p>\n<p>1\u3001\u6253\u5f00mysql\u914d\u7f6e\u6587\u4ef6\uff1avi \/etc\/my.cnf<\/p>\n<p>2\u3001\u5c06log-bin=mysql-bin\u548cbinlog_format=mixed \u8fd9\u4e24\u6761\u6ce8\u91ca\u6389\u5373\u53ef.<br \/>\n#log-bin=mysql-bin<br \/>\n#binlog_format=mixed<\/p>\n<p>\u95ee\u9898\u89e3\u7b54<\/p>\n<p>1\u3001mysql\u542f\u52a8\u9519\u8bef\uff1amysqld_safe mysqld from pid file \/var\/run\/mysqld\/mysqld.pid ended<br \/>\n\u4fee\u6539\uff1avi \/etc\/my.cnf<br \/>\n\u628a<\/p>\n<p>[mysqld_safe]<\/p>\n<p>err-log=\/var\/log\/mysqld.log<\/p>\n<p>pid-file=\/var\/lib\/<strong>run<\/strong>\/mysql\/mysqld.pid<\/p>\n<p>\u6539\u6210<\/p>\n<p>[mysqld_safe]<\/p>\n<p>err-log=\/var\/log\/mysqld.log<\/p>\n<p>pid-file=\/var\/lib\/mysql\/mysqld.pid<\/p>\n<p>2\u3001\u91cd\u88c5mysql\u540e\uff0c\u542f\u52a8\u5931\u8d25<br \/>\n\u5728\u91cd\u65b0\u5b89\u88c5mysql\u540e\u9700\u8981\u91cd\u65b0\u521d\u59cb\u5316\u4e0b\uff0c\u8bbe\u7f6e\u5bc6\u7801\uff0c\u529e\u6cd5\uff0c\u6267\u884c\uff1amysql_secure_installation<\/p>\n<p>3\u3001\u6570\u636e\u5e93\u5bfc\u5165\u4e2d\uff0c\u63d0\u793a\u9519\u8bef\uff1a#1115 \u2013 Unknown character set: \u2018utf8\u2019<br \/>\n\u628autf8 \u66ff\u6362\u6210 utf8 \u5c31\u53ef\u4ee5\u4e86<\/p>\n<p>4\u3001\u6570\u636e\u5e93\u5bfc\u5165\u4e2d\uff0c\u63d0\u793a\u9519\u8bef\uff1a#1153 \u2013 Got a packet bigger than \u2018max_allowed_packet\u2019 bytes<br \/>\n\u4fee\u6539\uff1avi \/etc\/my.cnf\u5c06max_allowed_packet\u503c\u8c03\u5927\u5373\u53ef<\/p>\n<p>5\u3001\u9047\u5230\u9519\u8befERROR 1186 (HY000): Binlog closed, cannot RESET MASTER<br \/>\n\u5f00\u542f\u670d\u52a1\u5668\u7684\u65e5\u5fd7\u7cfb\u7edf\uff0c\u4fee\u6539\uff1avi \/etc\/my.cnf\u53d6\u6d88\u6ce8\u91calog-bin=mysql-bin\u548cbinlog_format=mixed<\/p>\n<p>\u6280\u672f\u8bb0\u5f55<\/p>\n<p>1\u3001centos\u5f7b\u5e95\u5220\u9664mysql<\/p>\n<p>yum remove mysql mysql-server mysql-libs compat-mysql51<\/p>\n<p>rm -rf \/var\/lib\/mysql<\/p>\n<p>rm \/etc\/my.cnf<\/p>\n<p>\u67e5\u770b\u662f\u5426\u8fd8\u6709mysql\u8f6f\u4ef6\uff1a<\/p>\n<p>rpm -qa|grep mysql<\/p>\n<p>\u6709\u7684\u8bdd\u7ee7\u7eed\u5220\u9664<\/p>\n<p>2\u3001\u5b89\u88c5mysql<br \/>\n\uff081\uff09\u5b89\u88c5MySQL<\/p>\n<p>yum install mysql mysql-server #\u8be2\u95ee\u662f\u5426\u8981\u5b89\u88c5\uff0c\u8f93\u5165Y\u5373\u53ef\u81ea\u52a8\u5b89\u88c5,\u76f4\u5230\u5b89\u88c5\u5b8c\u6210<br \/>\n\/etc\/init.d\/mysqld start #\u542f\u52a8MySQL<br \/>\nchkconfig mysqld on #\u8bbe\u4e3a\u5f00\u673a\u542f\u52a8<br \/>\ncp \/usr\/share\/mysql\/my-medium.cnf \/etc\/my.cnf #\u62f7\u8d1d\u914d\u7f6e\u6587\u4ef6\uff08\u6ce8\u610f\uff1a\u5982\u679c\/etc\u76ee\u5f55\u4e0b\u9762\u9ed8\u8ba4\u6709\u4e00\u4e2amy.cnf\uff0c\u76f4\u63a5\u8986\u76d6\u5373\u53ef\uff09<br \/>\n\uff082\uff09\u4e3aroot\u8d26\u6237\u8bbe\u7f6e\u5bc6\u7801\uff1amysql_secure_installation\u540e\/etc\/init.d\/mysqld restart #\u91cd\u542f<\/p>\n<p>\uff083\uff09\u5b89\u88c5PHP\u7ec4\u4ef6\uff0c\u4f7f PHP5 \u652f\u6301 MySQL<\/p>\n<p>yum install php-mysql php-gd libjpeg* php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-mcrypt php-bcmath php-mhash libmcrypt<br \/>\n\/etc\/init.d\/mysqld restart #\u91cd\u542fMySql<br \/>\n\/etc\/init.d\/httpd restart #\u91cd\u542fApche<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u88c5\u65b0\u7248\u672c\u7684mysql 5.5\u65f6\uff0c\u9047\u5230\u4e86\u4e2a\u95ee\u9898\u65e0\u6cd5\u5b89\u88c5\uff0c\u63d0\u793a\u7cfb\u7edf\u7a7a\u95f4\u4e0d\u8db3\u3002\u4e8e\u662f\u6211\u5c31\u56f0\u60d1\u4e86\uff0c10G\u7684\u786c\u76d8\u4e0d\u4f1a\u56e0\u4e3a\u6302 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[4],"tags":[],"_links":{"self":[{"href":"https:\/\/kkong.net\/index.php?rest_route=\/wp\/v2\/posts\/32"}],"collection":[{"href":"https:\/\/kkong.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kkong.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kkong.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/kkong.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=32"}],"version-history":[{"count":5,"href":"https:\/\/kkong.net\/index.php?rest_route=\/wp\/v2\/posts\/32\/revisions"}],"predecessor-version":[{"id":108,"href":"https:\/\/kkong.net\/index.php?rest_route=\/wp\/v2\/posts\/32\/revisions\/108"}],"wp:attachment":[{"href":"https:\/\/kkong.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=32"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kkong.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=32"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kkong.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=32"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}