{"id":760,"date":"2017-01-11T14:05:24","date_gmt":"2017-01-11T06:05:24","guid":{"rendered":"http:\/\/www.shuran.cn\/?p=760"},"modified":"2017-01-11T14:05:24","modified_gmt":"2017-01-11T06:05:24","slug":"mysql%e5%86%85%e5%ad%98%e8%a1%a8%e7%9a%84%e7%89%b9%e6%80%a7%e4%b8%8e%e4%bd%bf%e7%94%a8%e4%bb%8b%e7%bb%8d","status":"publish","type":"post","link":"https:\/\/www.shuran.cn\/?p=760","title":{"rendered":"MySQL\u5185\u5b58\u8868\u7684\u7279\u6027\u4e0e\u4f7f\u7528\u4ecb\u7ecd"},"content":{"rendered":"<p style=\"color:#4B4B4B;font-family:Verdana, Arial, Helvetica, sans-serif;font-size:13px;background-color:#FFFFFF;\">\n\t<span style=\"color:#FF0000;\">\u5185\u5b58\u8868\uff0c\u5c31\u662f\u653e\u5728\u5185\u5b58\u4e2d\u7684\u8868\uff0c\u6240\u4f7f\u7528\u5185\u5b58\u7684\u5927\u5c0f\u53ef\u901a\u8fc7My.cnf\u4e2d\u7684max_heap_table_size\u6307\u5b9a\uff0c\u5982max_heap_table_size=1024M\uff0c<\/span>\n<\/p>\n<p style=\"color:#4B4B4B;font-family:Verdana, Arial, Helvetica, sans-serif;font-size:13px;background-color:#FFFFFF;\">\n\t<span style=\"color:#FF0000;\">\u5185\u5b58\u8868\u4e0e\u4e34\u65f6\u8868\u5e76\u4e0d\u76f8\u540c\uff0c\u4e34\u65f6\u8868\u4e5f\u662f\u5b58\u653e\u5728\u5185\u5b58\u4e2d\uff0c\u4e34\u65f6\u8868\u6700\u5927\u6240\u9700\u5185\u5b58\u9700\u8981\u901a\u8fc7tmp_table_size = 128M\u8bbe\u5b9a\u3002\u5f53\u6570\u636e\u8d85\u8fc7\u4e34\u65f6\u8868\u7684\u6700\u5927\u503c\u8bbe\u5b9a\u65f6\uff0c\u81ea\u52a8\u8f6c\u4e3a\u78c1\u76d8\u8868\uff0c\u6b64\u65f6\u56e0\u9700\u8981\u8fdb\u884cIO\u64cd\u4f5c\uff0c\u6027\u80fd\u4f1a\u5927\u5927\u4e0b\u964d\uff0c<\/span>\n<\/p>\n<p style=\"color:#4B4B4B;font-family:Verdana, Arial, Helvetica, sans-serif;font-size:13px;background-color:#FFFFFF;\">\n\t<span style=\"color:#FF0000;\">\u800c\u5185\u5b58\u8868\u4e0d\u4f1a\uff0c\u5185\u5b58\u8868\u6ee1\u540e\uff0c\u4f1a\u63d0\u793a\u6570\u636e\u6ee1\u9519\u8bef\u3002<\/span>\n<\/p>\n<p style=\"color:#4B4B4B;font-family:Verdana, Arial, Helvetica, sans-serif;font-size:13px;background-color:#FFFFFF;\">\n\t\u4e34\u65f6\u8868\u548c\u5185\u5b58\u8868\u90fd\u53ef\u4ee5\u4eba\u5de5\u521b\u5efa\uff0c\u4f46\u4e34\u65f6\u8868\u66f4\u591a\u7684\u4f5c\u7528\u662f\u7cfb\u7edf\u81ea\u5df1\u521b\u5efa\u540e\uff0c\u7ec4\u7ec7\u6570\u636e\u4ee5\u63d0\u5347\u6027\u80fd\uff0c\u5982\u5b50\u67e5\u8be2\uff0c\u4e34\u65f6\u8868\u5728\u591a\u4e2a\u8fde\u63a5\u4e4b\u95f4\u4e0d\u80fd\u5171\u4eab\u3002\u8fd9\u91cc\u53ea\u8ba8\u8bba\u5185\u5b58\u8868\n<\/p>\n<p style=\"color:#4B4B4B;font-family:Verdana, Arial, Helvetica, sans-serif;font-size:13px;background-color:#FFFFFF;\">\n\t\u521b\u5efa\u8868\u662f\uff0c\u7528engine=heap\u53ef\u521b\u5efa\uff08mysql5.5\u4e2d\u5df2\u7ecf\u4e0d\u652f\u6301type\uff0c\u4ee5\u540e\u90fd\u7528engine\uff0c\u5f62\u6210\u4e60\u60ef\uff09\u3002\n<\/p>\n<p style=\"color:#4B4B4B;font-family:Verdana, Arial, Helvetica, sans-serif;font-size:13px;background-color:#FFFFFF;\">\n\t\n<\/p>\n<pre class=\"prettyprint lang-js\">create table test(\r\n\tid int unsigned not null auto_increment primary key,\r\n\tstate char(10),\r\n\ttype char(20),\r\n\tdate char(30)\r\n)ENGINE=MEMORY DEFAULT CHARSET=utf8;<\/pre>\n<h4 style=\"font-size:14px;color:#4B4B4B;font-family:Verdana, Arial, Helvetica, sans-serif;background-color:#FFFFFF;\">\n\t\u5185\u5b58\u8868\u7684\u7279\u6027<br \/>\n<\/h4>\n<ol style=\"color:#4B4B4B;font-family:Verdana, Arial, Helvetica, sans-serif;font-size:13px;background-color:#FFFFFF;\">\n<ol>\n<li style=\"font-size:12px;\">\n\t\t\t\u5185\u5b58\u8868\u7684\u8868\u5b9a\u4e49\u662f\u5b58\u653e\u5728\u78c1\u76d8\u4e0a\u7684\uff0c\u6269\u5c55\u540d\u4e3a.frm\uff0c&nbsp;\u6240\u4ee5\u91cd\u542f\u4e0d\u4f1a\u4e22\u5931\u3002\n\t\t<\/li>\n<li style=\"font-size:12px;\">\n\t\t\t<span style=\"color:#FF0000;\">\u5185\u5b58\u8868\u7684\u6570\u636e\u662f\u5b58\u653e\u5728\u5185\u5b58\u4e2d\u7684\uff0c\u6240\u4ee5\u91cd\u542f\u4f1a\u4e22\u5931\u6570\u636e\u3002<\/span>\n\t\t<\/li>\n<li style=\"font-size:12px;\">\n\t\t\t\u5185\u5b58\u8868\u4f7f\u7528\u4e00\u4e2a\u56fa\u5b9a\u7684\u8bb0\u5f55\u957f\u5ea6\u683c\u5f0f\u3002\n\t\t<\/li>\n<li style=\"font-size:12px;\">\n\t\t\t<span style=\"color:#FF0000;\">\u5185\u5b58\u8868\u4e0d\u652f\u6301BLOB\u6216TEXT\u5217\uff0c\u6bd4\u5982varchar\u4e0etext\u5b57\u6bb5\u5c31\u4e0d\u4f1a\u88ab\u652f\u6301\u3002<\/span>\n\t\t<\/li>\n<li style=\"font-size:12px;\">\n\t\t\t\u5185\u5b58\u8868\u652f\u6301AUTO_INCREMENT\u5217\u548c\u5bf9\u53ef\u5305\u542bNULL\u503c\u7684\u5217\u7684\u7d22\u5f15\uff08\u7f51\u4e0a\u5927\u591a\u8bf4\u4e0d\u652f\u6301\uff0c\u8fd9\u662f\u9519\u8bef\u7684\uff09\u3002\u5185\u5b58\u8868\u652f\u6301\u5927\u4e8e(&gt;)&nbsp;\u5c0f\u4e8e(&nbsp;&lt;)\u64cd\u4f5c\uff0c\u7f51\u4e0a\u4e5f\u8bf4\u4e0d\u652f\u6301\u3002\n\t\t<\/li>\n<li style=\"font-size:12px;\">\n\t\t\t<span style=\"color:#FF0000;\">mysql\u91cd\u542f\u540e\uff0c\u4e3b\u952e\u3001\u81ea\u589e\u3001\u7d22\u5f15\u4ecd\u7136\u5b58\u5728\uff0c\u53ea\u662f\u6570\u636e\u4e22\u5931\u3002\u8fd9\u4e5f\u662f\u5bf9\u7f51\u4e0a\u7684\u4e00\u4e9b\u9519\u8bef\u6587\u5b57\u7ea0\u6b63\u3002<\/span>\n\t\t<\/li>\n<li style=\"font-size:12px;\">\n\t\t\t<span style=\"color:#FF0000;\">\u5185\u5b58\u8868\u8868\u5728\u6240\u6709\u5ba2\u6237\u7aef\u4e4b\u95f4\u5171\u4eab\uff08\u5c31\u50cf\u5176\u5b83\u4efb\u4f55\u975eTEMPORARY\u8868\uff09\u3002<\/span>\n\t\t<\/li>\n<li style=\"font-size:12px;\">\n\t\t\tMEMORY\u5b58\u50a8\u5f15\u64ce\u6267\u884cHASH\u548cBTREE\u7d22\u5f15\u3002\u4f60\u53ef\u4ee5\u901a\u8fc7\u6dfb\u52a0\u4e00\u4e2a\u5982\u4e0b\u6240\u793a\u7684USING\u5b50\u53e5\u4e3a\u7ed9\u5b9a\u7684\u7d22\u5f15\u6307\u5b9a\u4e00\u4e2a\u6216\u53e6\u4e00\u4e2a\uff1a\n\t\t<\/li>\n<\/ol>\n<\/ol>\n<p style=\"color:#4B4B4B;font-family:Verdana, Arial, Helvetica, sans-serif;font-size:13px;background-color:#FFFFFF;\">\n\t\n<\/p>\n<pre class=\"prettyprint lang-js\">\tCREATE TABLE lookup (id INT, INDEX USING HASH (id)) ENGINE = MEMORY;\r\n\tCREATE TABLE lookup (id INT, INDEX USING BTREE (id)) ENGINE = MEMORY;<\/pre>\n<p>\n\t\n<\/p>\n<p style=\"color:#4B4B4B;font-family:Verdana, Arial, Helvetica, sans-serif;font-size:13px;background-color:#FFFFFF;\">\n\t\n<\/p>\n<div id=\"highlighter_94839\" class=\"syntaxhighlighter \" style=\"font-size:13px;color:#4B4B4B;font-family:Verdana, Arial, Helvetica, sans-serif;margin:1em 0px !important;background-color:#FFFFFF !important;\">\n<div class=\"lines\" style=\"background:none !important;border:0px !important;margin:0px !important;padding:0px !important;vertical-align:baseline !important;font-family:Consolas, &quot;font-size:12px !important;\">\n<div class=\"line alt1\" style=\"border:0px !important;margin:0px !important;padding:0px !important;vertical-align:baseline !important;\">\n\t\t<\/div>\n<\/p><\/div>\n<\/div>\n<p>\n\t\u5185\u5b58\u8868\u521d\u59cb\u5316\uff0c\u53ef\u4ee5\u4f7f\u7528--init-file\u6765\u521d\u59cb\u5316\uff0c\u907f\u514d\u91cd\u542fmysql\u540e\u6570\u636e\u88ab\u6e05\u7a7a\u3002\u6bd4\u5982--init-file=\"\/data\/mysql\/init.sql\", init.sql\u683c\u5f0f\u4e3a\uff1a\n<\/p>\n<ol style=\"color:#4B4B4B;font-family:Verdana, Arial, Helvetica, sans-serif;font-size:13px;background-color:#FFFFFF;\">\n<li style=\"font-size:12px;\">\n\t\t\u5728\u6570\u636e\u5e93\u590d\u5236\u65f6\uff0c\u5982\u679c\u4e3b\u673a\u5f53\u6389\uff0c\u5219\u4f1a\u5728binLog\u4e2d\u81ea\u52a8\u52a0\u5165delete from [\u5185\u5b58\u8868]\uff0c\u5c06slave\u7684\u6570\u636e\u4e5f\u5220\u9664\u6389\uff0c\u4ee5\u4fdd\u8bc1\u4e24\u8fb9\u7684\u6570\u636e\u4e00\u81f4\u6027\u3002\n\t<\/li>\n<li style=\"font-size:12px;\">\n\t\t<span style=\"color:#FF0000;\">\u5185\u5b58\u8868\u4e0d\u652f\u6301\u4e8b\u52a1\u3002<\/span>\n\t<\/li>\n<li style=\"font-size:12px;\">\n\t\t<span style=\"color:#FF0000;\">\u5185\u5b58\u8868\u662f\u8868\u9501\uff0c\u5f53\u4fee\u6539\u9891\u7e41\u65f6\uff0c\u6027\u80fd\u53ef\u80fd\u4f1a\u4e0b\u964d\u3002<\/span>\n\t<\/li>\n<\/ol>\n<h4 style=\"font-size:14px;color:#4B4B4B;font-family:Verdana, Arial, Helvetica, sans-serif;background-color:#FFFFFF;\">\n\t\u5185\u5b58\u8868\u7684\u4f7f\u7528<br \/>\n<\/h4>\n<p style=\"color:#4B4B4B;font-family:Verdana, Arial, Helvetica, sans-serif;font-size:13px;background-color:#FFFFFF;\">\n\t\u5185\u5b58\u8868\u4f7f\u7528\u54c8\u5e0c\u6563\u5217\u7d22\u5f15\u628a\u6570\u636e\u4fdd\u5b58\u5728\u5185\u5b58\u4e2d\uff0c\u56e0\u6b64\u5177\u6709\u6781\u5feb\u7684\u901f\u5ea6\uff0c\u9002\u5408\u7f13\u5b58\u4e2d\u5c0f\u578b\u6570\u636e\u5e93\uff0c\u4f46\u662f\u4f7f\u7528\u4e0a\u53d7\u5230\u4e00\u4e9b\u9650\u5236\u3002\n<\/p>\n<ol style=\"color:#4B4B4B;font-family:Verdana, Arial, Helvetica, sans-serif;font-size:13px;background-color:#FFFFFF;\">\n<li style=\"font-size:12px;\">\n\t\theap \u5bf9\u6240\u6709\u7528\u6237\u7684\u8fde\u63a5\u662f\u53ef\u89c1\u7684\uff0c\u8fd9\u4f7f\u5f97\u5b83\u975e\u5e38\u9002\u5408\u505a\u7f13\u5b58\u3002\n\t<\/li>\n<li style=\"font-size:12px;\">\n\t\t\u4ec5\u9002\u5408\u4f7f\u7528\u7684\u573a\u5408\u3002heap\u4e0d\u5141\u8bb8\u4f7f\u7528xxxTEXT\u548cxxxBLOB\u6570\u636e\u7c7b\u578b\u3002\u6ce8\uff1a\u64cd\u4f5c\u7b26 \u201c&lt;=&gt;\u201d \u8bf4\u660e\uff1aNULL-safe equal.\u8fd9\u4e2a\u64cd\u4f5c\u7b26\u548c\u201c=\u201d\u64cd\u4f5c\u7b26\u6267\u884c\u76f8\u540c\u7684\u6bd4\u8f83\u64cd\u4f5c\uff0c\u4e0d\u8fc7\u5728\u4e24\u4e2a\u64cd\u4f5c\u7801\u5747\u4e3aNULL\u65f6\uff0c\u5176\u6240\u5f97\u503c\u4e3a1\u800c\u4e0d\u4e3aNULL\uff0c\u800c\u5f53\u4e00\u4e2a\u64cd\u4f5c\u7801\u4e3aNULL\u65f6\uff0c\u5176\u6240\u5f97\u503c\u4e3a0\u800c\u4e0d\u4e3aNULL\u3002\n\t<\/li>\n<li style=\"font-size:12px;\">\n\t\t\u4e00\u65e6\u670d\u52a1\u5668\u91cd\u542f\uff0c\u6240\u6709heap\u8868\u6570\u636e\u4e22\u5931\uff0c\u4f46\u662fheap\u8868\u7ed3\u6784\u4ecd\u7136\u5b58\u5728\uff0c\u56e0\u4e3aheap\u8868\u7ed3\u6784\u662f\u5b58\u653e\u5728\u5b9e\u9645\u6570\u636e\u5e93\u8def\u5f84\u4e0b\u7684\uff0c\u4e0d\u4f1a\u81ea\u52a8\u5220\u9664\u3002\u91cd\u542f\u4e4b\u540e\uff0cheap\u5c06\u88ab\u6e05\u7a7a\uff0c\u8fd9\u65f6\u5019\u5bf9heap\u7684\u67e5\u8be2\u7ed3\u679c\u90fd\u662f\u7a7a\u7684\u3002\n\t<\/li>\n<li style=\"font-size:12px;\">\n\t\t\u5982\u679cheap\u662f\u590d\u5236\u7684\u67d0\u6570\u636e\u8868\uff0c\u5219\u590d\u5236\u4e4b\u540e\u6240\u6709\u4e3b\u952e\u3001\u7d22\u5f15\u3001\u81ea\u589e\u7b49\u683c\u5f0f\u5c06\u4e0d\u590d\u5b58\u5728\uff0c\u9700\u8981\u91cd\u65b0\u6dfb\u52a0\u4e3b\u952e\u548c\u7d22\u5f15\uff0c\u5982\u679c\u9700\u8981\u7684\u8bdd\u3002\n\t<\/li>\n<li style=\"font-size:12px;\">\n\t\t\u5bf9\u4e8e\u91cd\u542f\u9020\u6210\u7684\u6570\u636e\u4e22\u5931\uff0c\u6709\u4ee5\u4e0b\u7684\u89e3\u51b3\u529e\u6cd5\uff1a\n\t<\/li>\n<ul style=\"font-size:11px;\">\n<li>\n\t\t\t\u5728\u4efb\u4f55\u67e5\u8be2\u4e4b\u524d\uff0c\u6267\u884c\u4e00\u6b21\u7b80\u5355\u7684\u67e5\u8be2\uff0c\u5224\u65adheap\u8868\u662f\u5426\u5b58\u5728\u6570\u636e\uff0c\u5982\u679c\u4e0d\u5b58\u5728\uff0c\u5219\u628a\u6570\u636e\u91cd\u65b0\u5199\u5165\uff0c\u6216\u8005DROP\u8868\u91cd\u65b0\u590d\u5236\u67d0\u5f20\u8868\u3002\u8fd9\u9700\u8981\u591a\u505a\u4e00\u6b21\u67e5\u8be2\u3002\u4e0d\u8fc7\u53ef\u4ee5\u5199\u6210include\u6587\u4ef6\uff0c\u5728\u9700\u8981\u7528\u8be5heap\u8868\u7684\u9875\u9762\u968f\u65f6\u8c03\u7528\uff0c\u6bd4\u8f83\u65b9\u4fbf\u3002\n\t\t<\/li>\n<li>\n\t\t\t\u5bf9\u4e8e\u9700\u8981\u8be5heap\u8868\u7684\u9875\u9762\uff0c\u5728\u8be5\u9875\u9762\u7b2c\u4e00\u6b21\u4e14\u4ec5\u5728\u7b2c\u4e00\u6b21\u67e5\u8be2\u8be5\u8868\u65f6\uff0c\u5bf9\u6570\u636e\u96c6\u7ed3\u679c\u8fdb\u884c\u5224\u65ad\uff0c\u5982\u679c\u7ed3\u679c\u4e3a\u7a7a\uff0c\u5219\u9700\u8981\u91cd\u65b0\u5199\u5165\u6570\u636e\u3002\u8fd9\u6837\u53ef\u4ee5\u8282\u7701\u4e00\u6b21\u67e5\u8be2\u3002\n\t\t<\/li>\n<li>\n\t\t\t\u66f4\u597d\u7684\u529e\u6cd5\u662f\u5728mysql\u6bcf\u6b21\u91cd\u65b0\u542f\u52a8\u65f6\u81ea\u52a8\u5199\u5165\u6570\u636e\u5230heap\uff0c\u4f46\u662f\u9700\u8981\u914d\u7f6e\u670d\u52a1\u5668\uff0c\u8fc7\u7a0b\u6bd4\u8f83\u590d\u6742\uff0c\u901a\u7528\u6027\u53d7\u5230\u9650\u5236\u3002\n\t\t<\/li>\n<\/ul>\n<\/ol>\n<h2>\n\t\u89e3\u51b3mysql\u5185\u5b58\u8868\u7684\u6570\u636e\u6301\u4e45\u6027\u95ee\u9898<br \/>\n<\/h2>\n<p style=\"color:#4B4B4B;font-family:Verdana, Arial, Helvetica, sans-serif;font-size:13px;background-color:#FFFFFF;\">\n\t\n<\/p>\n<p style=\"color:#333333;font-family:Arial;font-size:14px;background-color:#FFFFFF;\">\n\t\u540e\u53f0\u670d\u52a1\u4e2d\u5f80\u5f80\u8981\u6839\u636e\u4e0d\u540c\u7684\u9700\u8981\u91c7\u7528\u4e0d\u540c\u7684\u6570\u636e\u83b7\u53d6\u65b9\u6848\u3002\n<\/p>\n<p style=\"color:#333333;font-family:Arial;font-size:14px;background-color:#FFFFFF;\">\n\t\u4e3a\u4e86\u4fdd\u8bc1\u7cfb\u7edf\u7684\u9ad8\u6027\u80fd\uff0c\u6211\u4eec\u4e00\u822c\u91c7\u53d6\u4e0b\u97622\u79cd\u65b9\u6848\u89e3\u51b3\n<\/p>\n<p style=\"color:#333333;font-family:Arial;font-size:14px;background-color:#FFFFFF;\">\n\t1. Cache\n<\/p>\n<p style=\"color:#333333;font-family:Arial;font-size:14px;background-color:#FFFFFF;\">\n\t\u5927\u591a\u6570\u7cfb\u7edf\u90fd\u662f\u91c7\u7528\u5404\u79cdCache \u7cfb\u7edf\u6765\u8fdb\u884c\u6570\u636e\u7f13\u5b58\u7684\uff0c\u4f46\u76ee\u524d\u7684Cache\u7cfb\u7edf\u666e\u904d\u5b58\u5728\u7684\u95ee\u9898\u662f\u4ec5\u63d0\u4f9b\u4e86\u7b80\u5355\u7684\u6570\u636e\u5b58\u50a8\uff0c\u4f46\u4e0d\u80fd\u63d0\u4f9b\u6570\u636e\u7ec4\u7ec7\uff0c\u8ba1\u7b97\u7b49\u903b\u8f91\u529f\u80fd\u3002\n<\/p>\n<p style=\"color:#333333;font-family:Arial;font-size:14px;background-color:#FFFFFF;\">\n\t2. \u5185\u5b58\u8868\n<\/p>\n<p style=\"color:#333333;font-family:Arial;font-size:14px;background-color:#FFFFFF;\">\n\t\u591a\u6570\u7cfb\u7edf\u540e\u53f0DB\u4f7f\u7528\u7684\u662fMysql\uff0cMysql\u63d0\u4f9b\u4e00\u79cd\u7279\u6b8a\u7684\u5b58\u50a8\u5f15\u64ce\uff08HEAP\uff09\uff0c\u8fd9\u4e2a\u5373\u662fMysql\u7684\u5185\u5b58\u8868\u65b9\u6848\u3002\u4f46Mysql\u5185\u5b58\u8868\u4e0d\u63d0\u4f9b\u6570\u636e\u7684\u6301\u4e45\u6027\u80fd\u529b\uff0cDB\u5d29\u6e83\uff0c\u91cd\u542f\u540e\u6570\u636e\u5373\u6d88\u606f\uff0c\u8fd9\u5bf9\u4e8e\u90e8\u5206\u4e1a\u52a1\u6765\u8bf4\u662f\u4e0d\u53ef\u63a5\u53d7\u7684\u3002\n<\/p>\n<p style=\"color:#333333;font-family:Arial;font-size:14px;background-color:#FFFFFF;\">\n\t<strong>\u4e0b\u9762\u4ee5\u4e00\u4e2a\u7b80\u5355\u7684\u4f8b\u5b50\u6765\u63cf\u8ff0\u8fd9\u79cd\u65b9\u6cd5\uff1a<\/strong>\n<\/p>\n<p style=\"color:#333333;font-family:Arial;font-size:14px;background-color:#FFFFFF;\">\n\t1. \u5efa\u7acb\u5185\u5b58\u8868\uff1a\n<\/p>\n<p><pre class=\"prettyprint lang-js\">CREATE TABLE `t_music_list` (\r\n`Fmusic_id` varchar(12) NOT NULL default '',\r\n`Fmusic_name` varchar(64) NOT NULL default '',\r\n`Fstatus` int(11) NOT NULL default '0',\r\n`Ftry_count` int(11) NOT NULL default '0',\r\n`Flisten_count` int(11) NOT NULL default '0',\r\n`Ffee` int(11) NOT NULL default '0',\r\n`Fdesc` varchar(255) NOT NULL default '',\r\n`Fsinger_name` varchar(32) NOT NULL default '',\r\n`Fsinger_gender` varchar(6) NOT NULL default '',\r\n`Fsinger_type` varchar(16) NOT NULL default '',\r\n`Fcopy_right` int(11) NOT NULL default '0',\r\nPRIMARY KEY (`Fmusic_id`),\r\nKEY `Fmusic_name` (`Fmusic_name`,`Flisten_count`)\r\n) ENGINE=HEAP DEFAULT CHARSET=latin1;<\/pre>\n<\/p>\n<p><p style=\"color:#333333;font-family:Arial;font-size:14px;background-color:#FFFFFF;\">\n\t\t---\u8fd9\u662f\u4e00\u4e2a\u6b4c\u66f2\u5e93\u7684DB\u4f8b\u5b50\uff0c\u7531\u4e8e\u9700\u8981\u9891\u7e41\u7684\u67e5\u8be2\uff0c\u4fee\u6539\uff0c\u4ee5\u53ca\u4e1a\u52a1\u9700\u8981\u8fdb\u884c\u8f83\u590d\u6742\u7684\u6392\u540d\u641c\u7d22\u7b49\u903b\u8f91\u64cd\u4f5c\uff0c\u56e0\u6b64\u91c7\u7528\u4e86\u8fd9\u79cd\u673a\u5236\u3002\n\t<\/p>\n<p style=\"color:#333333;font-family:Arial;font-size:14px;background-color:#FFFFFF;\">\n\t\t2. \u751f\u6210\u5feb\u7167\u811a\u672c ---&nbsp;&nbsp; snapshot_music_list.sh\n\t<\/p>\n<p><pre class=\"prettyprint lang-js\">src_port=3306\r\nuser='xxx'\r\npass='xxx'\r\nFOLD='\/data\/t_music_list.log'\r\ndstfile='\/data\/t_music_list.dat'\r\nif [ -f \"$dstfile\" ] ;\r\nthen\r\n        mv $dstfile ${dstfile}_bak\r\nfi\r\n$MYSQL &gt;&gt; ${FOLD} -u${user} -h${src_host} -P${src_port} -p${pass} -f -N &lt;&lt;!\r\nselect * from myDB.t_music_list into outfile '${dstfile}';\r\n!\r\nfilezize=`du -b $dstfile| awk '{print $1}'`\r\nif [ $filezize -lt 2048 ] ;\r\nthen\r\n        echo \"Dest file too slow, recover it by backedfile.\"\r\n        mv ${dstfile}_bak $dstfile\r\nfi<\/pre>\n<p><span style=\"color:#333333;font-family:Arial;font-size:14px;background-color:#FFFFFF;\">---\u7528crontab \u5b9a\u65f6\u6267\u884c<\/span>\n\t<\/p>\n<p><pre class=\"prettyprint lang-js\">*\/5 * * * * \/usr\/local\/app\/tools\/ snapshot_music_list.sh &gt;\/dev\/null 2&gt;<\/pre>\n<p style=\"color:#333333;font-family:Arial;font-size:14px;background-color:#FFFFFF;\">\n\t\t\t3. mysql\u542f\u52a8\u65f6\u8fdb\u884c\u6570\u636e\u6062\u590d&nbsp;&nbsp; \u542f\u52a8\u65f6\u6267\u884c\u6062\u590d\u811a\u672c\uff0c\u6062\u590d\u811a\u672c\u8d1f\u8d23\u5c06\u5feb\u7167\u6570\u636e\u91cd\u65b0\u5bfc\u5165DB\n\t\t<\/p>\n<p style=\"color:#333333;font-family:Arial;font-size:14px;background-color:#FFFFFF;\">\n\t\t\t\u6570\u636e\u6062\u590d\u811a\u672c ---initdb.sql\n\t\t<\/p>\n<pre class=\"prettyprint lang-js\">load data infile '\/data\/t_music_list.dat' into table myDB.t_music_list;<\/pre>\n<p style=\"color:#333333;font-family:Arial;font-size:14px;background-color:#FFFFFF;\">\n\t\t\tmysql\u542f\u52a8\u914d\u7f6e&nbsp;&nbsp;&nbsp; --- my.cnf\n\t\t<\/p>\n<p style=\"color:#333333;font-family:Arial;font-size:14px;background-color:#FFFFFF;\">\n\t\t\t[mysqld]\n\t\t<\/p>\n<p style=\"color:#333333;font-family:Arial;font-size:14px;background-color:#FFFFFF;\">\n\t\t\t<strong>init-file&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = \/usr\/local\/app\/tools\/initdb.sql<\/strong>\n\t\t<\/p>\n<\/p>\n<p style=\"color:#4B4B4B;font-family:Verdana, Arial, Helvetica, sans-serif;font-size:13px;background-color:#FFFFFF;\">\n\t<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5185\u5b58\u8868\uff0c\u5c31\u662f\u653e\u5728\u5185\u5b58\u4e2d\u7684\u8868\uff0c\u6240\u4f7f\u7528\u5185\u5b58\u7684\u5927\u5c0f\u53ef\u901a\u8fc7My.cnf\u4e2d\u7684max_heap_table_size\u6307\u5b9a\uff0c\u2026 <span class=\"read-more\"><a href=\"https:\/\/www.shuran.cn\/?p=760\">Read More &raquo;<\/a><\/span><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[10],"tags":[],"class_list":["post-760","post","type-post","status-publish","format-standard","hentry","category-os"],"_links":{"self":[{"href":"https:\/\/www.shuran.cn\/index.php?rest_route=\/wp\/v2\/posts\/760","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.shuran.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.shuran.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.shuran.cn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.shuran.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=760"}],"version-history":[{"count":1,"href":"https:\/\/www.shuran.cn\/index.php?rest_route=\/wp\/v2\/posts\/760\/revisions"}],"predecessor-version":[{"id":761,"href":"https:\/\/www.shuran.cn\/index.php?rest_route=\/wp\/v2\/posts\/760\/revisions\/761"}],"wp:attachment":[{"href":"https:\/\/www.shuran.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=760"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.shuran.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=760"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.shuran.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=760"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}