{"id":258,"date":"2018-11-11T19:59:16","date_gmt":"2018-11-11T11:59:16","guid":{"rendered":"http:\/\/kaispace.cn\/?p=258"},"modified":"2018-11-11T19:59:16","modified_gmt":"2018-11-11T11:59:16","slug":"%e5%85%b3%e4%ba%8emysql%e9%9d%9e%e6%b3%95%e8%bf%9e%e6%8e%a5%e5%b0%9d%e8%af%95%e7%9a%84%e8%a7%a3%e5%86%b3%e6%96%b9%e6%b3%95%e4%bc%9a%e8%af%9d%e6%8e%a7%e5%88%b6%e6%8f%92%e4%bb%b6connection_control","status":"publish","type":"post","link":"https:\/\/blog.kaispace.cn\/?p=258","title":{"rendered":"\u5173\u4e8eMysql\u975e\u6cd5\u8fde\u63a5\u5c1d\u8bd5\u7684\u89e3\u51b3\u65b9\u6cd5(\u4f1a\u8bdd\u63a7\u5236\u63d2\u4ef6CONNECTION_CONTROL)"},"content":{"rendered":"<p>\u6700\u8fd1Mysql\u4e00\u76f4\u51fa\u73b0\u5d29\u6e83\u95ee\u9898\uff0c\u5728\u6392\u67e5\u9519\u8beflog\u6587\u4ef6\u65f6\u53d1\u73b0\u4e00\u76f4\u6709\u975e\u6cd5IP\u8fdb\u884croot\u8d26\u53f7\u7684\u5c1d\u8bd5\u767b\u9646\uff0c\u60f3\u5230\u4e4b\u524dssh\u4e5f\u7ecf\u53d7\u8fc7\u7c7b\u4f3c\u8fd9\u79cd\u65e0\u5dee\u522b\u5f0f\u653b\u51fb\uff0c\u6240\u4ee5\u60f3\u89e3\u51b3\u4e00\u4e0b\u3002\u8fd9\u91cc\u4e86\u89e3\u5230Mysql\u539f\u751f\u81ea\u5e26\u6709\u5404\u7c7b\u63d2\u4ef6\u3002<\/p>\n<p>\u8fd9\u91cc\u53ef\u4ee5\u901a\u8fc7<\/p>\n<blockquote><p>USE information_schema;SELECT PLUGIN_NAME,PLUGIN_STATUS FROM PLUGINS;<\/p><\/blockquote>\n<p>\u67e5\u770b\u6240\u6709\u63d2\u4ef6<\/p>\n<p><span style=\"color: #333333;\">\u5728Mysql\u5b98\u7f51\u7684\u5b89\u5168\u63d2\u4ef6\u4e2d\u6709\u4e24\u4e2a\u63a7\u5236\u4f1a\u8bdd\u7684\u63d2\u4ef6\u53eb\u505a<span style=\"color: #ff0000;\">CONNECTION_CONTROL<span style=\"color: #333333;\">\u548c<\/span>CONNECTION_CONTROL_FAILED_LOGIN_ATTEMPTS<\/span><\/span><\/p>\n<p><span style=\"color: #333333;\">\u8fd9\u91cc\u5c31\u662f\u901a\u8fc7\u8fd9\u4e24\u4e2a\u63d2\u4ef6\u5b9e\u73b0<\/span><\/p>\n<p>\u7b2c\u4e00\u6b65:\u5728Mysql\u767b\u5165\u540e\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\u5b89\u88c5\u63d2\u4ef6<\/p>\n<blockquote><p><strong><span class=\"token keyword\">INSTALL<\/span> <span class=\"token keyword\">PLUGIN<\/span> CONNECTION_CONTROL <span class=\"token keyword\">SONAME<\/span> <span class=\"token string\">&#8216;connection_control.so&#8217;<\/span><span class=\"token punctuation\">;<\/span><\/strong><\/p>\n<p><strong><span class=\"token keyword\">INSTALL<\/span> <span class=\"token keyword\">PLUGIN<\/span> CONNECTION_CONTROL_FAILED_LOGIN_ATTEMPTS <span class=\"token keyword\">SONAME<\/span> <span class=\"token string\">&#8216;connection_control.so&#8217;<\/span><span class=\"token punctuation\">;<\/span><\/strong><\/p><\/blockquote>\n<p>\u7b2c\u4e8c\u6b65:\u4fee\u6539my.cnf\u6587\u4ef6(Mysql\u914d\u7f6e\u6587\u4ef6,\u82e5\u4e0d\u77e5\u9053\u4f4d\u7f6e\u53ef\u4ee5whereis my.cnf),\u52a0\u5165\u4ee5\u4e0b\u9009\u9879<\/p>\n<blockquote><p><strong><span class=\"token constant\">plugin-load-add<\/span><span class=\"token attr-value\"><span class=\"token punctuation\">=<\/span>connection_control.so#\u63d2\u4ef6\u9884\u52a0\u8f7d<\/span><\/strong><\/p>\n<p><strong><span class=\"token constant\">connection-control<\/span><span class=\"token attr-value\"><span class=\"token punctuation\">=<\/span>FORCE_PLUS_PERMANENT#\u5f3a\u5236\u6253\u5f00\u63d2\u4ef6<\/span><\/strong><\/p>\n<p><strong><span class=\"token constant\">connection-control-failed-login-attempts<\/span><span class=\"token attr-value\"><span class=\"token punctuation\">=<\/span>FORCE_PLUS_PERMANENT#\u5f3a\u5236\u6253\u5f00\u63d2\u4ef6<\/span><\/strong><\/p>\n<p><strong><span class=\"token constant\">connection_control_failed_connections_threshold<\/span><span class=\"token attr-value\"><span class=\"token punctuation\">=<\/span>4#\u8d85\u8fc7\u8fd9\u4e2a\u503c\u5c31\u5f00\u8d77\u5ef6\u65f6<\/span><\/strong><\/p>\n<p><strong><span class=\"token constant\">connection_control_min_connection_delay<\/span><span class=\"token attr-value\"><span class=\"token punctuation\">=<\/span>1500#\u5931\u8d25\u540e\u7b49\u5f851500\u6beb\u79d2<\/span><\/strong><\/p><\/blockquote>\n<p>\u68c0\u67e5:<\/p>\n<blockquote><p><strong><span class=\"token keyword\">SELECT<\/span> PLUGIN_NAME<span class=\"token punctuation\">,<\/span> PLUGIN_STATUS <span class=\"token keyword\">FROM<\/span> INFORMATION_SCHEMA<span class=\"token punctuation\">.<\/span><span class=\"token keyword\">PLUGINS<\/span> <span class=\"token keyword\">WHERE<\/span> PLUGIN_NAME <span class=\"token operator\">LIKE<\/span> <span class=\"token string\">&#8216;connection%&#8217;<\/span><span class=\"token punctuation\">;<\/span><\/strong><\/p><\/blockquote>\n<p>\u53ef\u67e5\u770b\u63d2\u4ef6\u6253\u5f00\u60c5\u51b5<\/p>\n<p>\u8fd9\u91cc\u6ce8\u610f\u7684\u662fdelay\u7684\u503c\u5e76\u4e0d\u662f\u8bf4\u6bcf\u6b21\u90fd\u662f1500\u6beb\u79d2\uff0c\u800c\u662f\u4ee5(\u5f53\u524d\u5931\u8d25\u603b\u6b21\u6570-\u5931\u8d25\u9608\u503c)*1500,\u6240\u4ee5\u5047\u5982\u5f53\u524d\u8bbe\u5b9a\u4e3a\u4e0a\uff0c\u5f53\u6211\u5931\u8d25\u767b\u9646\u7b2c6\u6b21\u65f6\uff0c\u6211\u7684\u7b49\u5f85\u65f6\u95f4\u4e0d\u662f1.5\u79d2\u800c\u662f3\u79d2\uff0c\u8fd8\u6709\u5c31\u662f\u60f3\u4e0d\u8ba9\u5c1d\u8bd5\u767b\u9646\u8d85\u8fc7\u4e00\u6b21\uff0c\u53ef\u4ee5\u628a\u9608\u503c\u6539\u4e3a0\u3002<\/p>\n<h4>\u5f00\u542f\u63d2\u4ef6\u540e\u81ea\u5df1\u767b\u9646\u5931\u8d25\u7684\u89e3\u51b3\u65b9\u6cd5:<\/h4>\n<blockquote><p><strong>1.\u91cd\u542f\u670d\u52a1\uff0c\u91cd\u542f\u670d\u52a1\u540e\u4f1a\u5237\u65b0CONNECTION_CONTROL_FAILED_LOGIN_ATTEMPTS\u8868\u4e0b\u8d26\u53f7\u7684\u5bf9\u5e94\u5931\u8d25\u767b\u5f55\u9519\u8bef\u6b21\u6570<\/strong><\/p>\n<p><strong>2.\u4fee\u6539\u4e0a\u8ff0\u7684\u8868\u5185\u5bb9\uff0c\u524d\u63d0\u662f\u4f60\u6709\u5176\u4ed6\u5bf9\u5e94\u6743\u9650\u7684\u8d26\u53f7\u767b\u5f55\u8fdb\u884c<\/strong><\/p><\/blockquote>\n<p><a href=\"https:\/\/dev.mysql.com\/doc\/refman\/5.7\/en\/connection-control-installation.html\">\u8fd9\u4e2a\u63d2\u4ef6\u7684\u4f7f\u7528\u5b98\u65b9\u6587\u6863<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6700\u8fd1Mysql\u4e00\u76f4\u51fa\u73b0\u5d29\u6e83\u95ee\u9898\uff0c\u5728\u6392\u67e5\u9519\u8beflog\u6587\u4ef6\u65f6\u53d1\u73b0\u4e00\u76f4\u6709\u975e\u6cd5IP\u8fdb\u884croot\u8d26\u53f7\u7684\u5c1d\u8bd5\u767b\u9646\uff0c\u60f3\u5230\u4e4b\u524ds&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[16],"tags":[],"_links":{"self":[{"href":"https:\/\/blog.kaispace.cn\/index.php?rest_route=\/wp\/v2\/posts\/258"}],"collection":[{"href":"https:\/\/blog.kaispace.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.kaispace.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.kaispace.cn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.kaispace.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=258"}],"version-history":[{"count":0,"href":"https:\/\/blog.kaispace.cn\/index.php?rest_route=\/wp\/v2\/posts\/258\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.kaispace.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=258"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.kaispace.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=258"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.kaispace.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=258"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}