{"id":168,"date":"2025-04-17T07:13:19","date_gmt":"2025-04-17T07:13:19","guid":{"rendered":"http:\/\/www.zhangwk.cn\/?p=168"},"modified":"2025-04-17T07:45:56","modified_gmt":"2025-04-17T07:45:56","slug":"mysql%e6%95%b0%e6%8d%ae%e5%ba%93%e5%a2%9e%e5%88%a0%e6%94%b9%e6%9f%a5","status":"publish","type":"post","link":"https:\/\/www.zhangwk.cn\/index.php\/2025\/04\/17\/mysql%e6%95%b0%e6%8d%ae%e5%ba%93%e5%a2%9e%e5%88%a0%e6%94%b9%e6%9f%a5\/","title":{"rendered":"mysql\u6570\u636e\u5e93\u589e\u5220\u6539\u67e5"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">MySQL \u6570\u636e\u5e93\u64cd\u4f5c\u547d\u4ee4\u6307\u5357\uff082025\u5e74\u6700\u65b0\uff09<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u200c\u4e00\u3001\u589e\u5220\u6539\u67e5 (CRUD) \u64cd\u4f5c\u200c<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u200c\u6570\u636e\u63d2\u5165\u200c<\/p>\n\n\n\n<pre class=\"wp-block-preformatted has-luminous-vivid-orange-color has-pale-ocean-gradient-background has-text-color has-background has-link-color wp-elements-883b7b9502659e1bb9c44aa03d1d52f5\">INSERT INTO \u8868\u540d (\u5b57\u6bb51, \u5b57\u6bb52) VALUES (\u503c1, \u503c2);  -- \u63d2\u5165\u6307\u5b9a\u5b57\u6bb5\u6570\u636e\u2022:ml-citation{ref=\"1,2\" data=\"citationList\"}  <\/pre>\n\n\n\n<pre class=\"wp-block-preformatted has-luminous-vivid-orange-color has-pale-ocean-gradient-background has-text-color has-background has-link-color wp-elements-dce4fe060c6614b32b3707b58fc46cbf\">INSERT INTO \u8868\u540d VALUES (\u503c1, \u503c2);                -- \u63d2\u5165\u5168\u5b57\u6bb5\u6570\u636e\u2022:ml-citation{ref=\"1,2\" data=\"citationList\"}<\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\">\u2022\u6570\u636e\u5220\u9664\u2022<\/pre>\n\n\n\n<pre class=\"wp-block-preformatted has-luminous-vivid-orange-color has-pale-ocean-gradient-background has-text-color has-background has-link-color wp-elements-99f2eed5a91aea440c43216291e06e0d\">DELETE FROM \u8868\u540d WHERE \u6761\u4ef6;  -- \u5220\u9664\u7b26\u5408\u6761\u4ef6\u7684\u6570\u636e\u2022:ml-citation{ref=\"1,2\" data=\"citationList\"}<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u200c\u6570\u636e\u4fee\u6539\u200c<\/p>\n\n\n\n<pre class=\"wp-block-preformatted has-luminous-vivid-orange-color has-pale-ocean-gradient-background has-text-color has-background has-link-color wp-elements-d8ededb082db0aae9e922a6cf64b5279\">UPDATE \u8868\u540d SET \u5b57\u6bb51=\u65b0\u503c WHERE \u6761\u4ef6;  -- \u66f4\u65b0\u6307\u5b9a\u5b57\u6bb5\u6570\u636e\u2022:ml-citation{ref=\"1,2\" data=\"citationList\"}<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u200c\u6570\u636e\u67e5\u8be2\u200c<\/p>\n\n\n\n<pre class=\"wp-block-preformatted has-luminous-vivid-orange-color has-pale-ocean-gradient-background has-text-color has-background has-link-color wp-elements-a376da0304e6623a6d6ac58d5ad963d3\">SELECT \u5b57\u6bb5\u5217\u8868 FROM \u8868\u540d WHERE \u6761\u4ef6;          -- \u57fa\u7840\u67e5\u8be2\u2022:ml-citation{ref=\"1,2\" data=\"citationList\"}  <\/pre>\n\n\n\n<pre class=\"wp-block-preformatted has-luminous-vivid-orange-color has-pale-ocean-gradient-background has-text-color has-background has-link-color wp-elements-1c85344f7bab1bee12d2274617150173\">SELECT * FROM \u8868\u540d LIMIT 10;                 -- \u5206\u9875\u67e5\u8be2\u2022:ml-citation{ref=\"1,8\" data=\"citationList\"}  <\/pre>\n\n\n\n<pre class=\"wp-block-preformatted has-luminous-vivid-orange-color has-pale-ocean-gradient-background has-text-color has-background has-link-color wp-elements-2490f1c106caefc32ce363159a320cc8\">SELECT \u5b57\u6bb5\u540d FROM \u8868\u540d ORDER BY \u5b57\u6bb5 DESC;   -- \u6392\u5e8f\u67e5\u8be2\u2022:ml-citation{ref=\"1,8\" data=\"citationList\"}<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u200c\u4e8c\u3001\u5f00\u542f\/\u5173\u95ed\u8fdc\u7a0b\u8bbf\u95ee\u200c<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u200c\u5f00\u542f\u8fdc\u7a0b\u8bbf\u95ee\u200c<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u200c\u6388\u6743\u7528\u6237\u8fdc\u7a0b\u767b\u5f55\u200c<\/p>\n\n\n\n<pre class=\"wp-block-preformatted has-luminous-vivid-orange-color has-pale-ocean-gradient-background has-text-color has-background has-link-color wp-elements-1451d6bb2e3cd3383ceb96d37adb3a0c\">GRANT ALL PRIVILEGES ON *.* TO '\u7528\u6237\u540d'@'%' IDENTIFIED BY '\u5bc6\u7801';  -- \u5141\u8bb8\u6240\u6709IP\u8bbf\u95ee\u2022:ml-citation{ref=\"4,5\" data=\"citationList\"}  <\/pre>\n\n\n\n<pre class=\"wp-block-preformatted has-luminous-vivid-orange-color has-pale-ocean-gradient-background has-text-color has-background has-link-color wp-elements-db6dd60e2e31f960efb195cb8f275cfb\">FLUSH PRIVILEGES;  -- \u5237\u65b0\u6743\u9650\u2022:ml-citation{ref=\"4,5\" data=\"citationList\"}<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u200c\u4fee\u6539\u914d\u7f6e\u6587\u4ef6\u200c<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u6ce8\u91ca my.cnf \u4e2d\u7684 bind-address = 127.0.0.1\uff0c\u91cd\u542f\u670d\u52a1\u200c\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u200c\u5173\u95ed\u8fdc\u7a0b\u8bbf\u95ee\u200c<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u200c\u5220\u9664\u8fdc\u7a0b\u6743\u9650\u7528\u6237\u200c<\/p>\n\n\n\n<pre class=\"wp-block-preformatted has-luminous-vivid-orange-color has-pale-ocean-gradient-background has-text-color has-background has-link-color wp-elements-3026ff4db47fdb7865bb46375dab6db9\">DELETE FROM mysql.user WHERE User='\u7528\u6237\u540d' AND Host='%';  -- \u5220\u9664\u5141\u8bb8\u4efb\u610fIP\u7684\u7528\u6237\u2022:ml-citation{ref=\"5,6\" data=\"citationList\"}  <\/pre>\n\n\n\n<pre class=\"wp-block-preformatted has-luminous-vivid-orange-color has-pale-ocean-gradient-background has-text-color has-background has-link-color wp-elements-56a165f3a675ddf2d5ed29117e3edd19\">FLUSH PRIVILEGES;  -- \u7acb\u5373\u751f\u6548\u2022:ml-citation{ref=\"5,6\" data=\"citationList\"}<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u200c\u9650\u5236\u7528\u6237\u8bbf\u95eeIP\u200c<\/p>\n\n\n\n<pre class=\"wp-block-preformatted has-luminous-vivid-orange-color has-pale-ocean-gradient-background has-text-color has-background has-link-color wp-elements-eefe808e866cdb8ed710c8c0fa4ce3a7\">UPDATE mysql.user SET Host='192.168.1.%' WHERE User='\u7528\u6237\u540d';  -- \u4ec5\u5141\u8bb8\u7279\u5b9a\u7f51\u6bb5\u8bbf\u95ee\u2022:ml-citation{ref=\"6,7\" data=\"citationList\"}<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u200c\u4e09\u3001\u7528\u6237\u6743\u9650\u7ba1\u7406\u200c<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u200c\u521b\u5efa\u7528\u6237\u200c<\/p>\n\n\n\n<pre class=\"wp-block-preformatted has-luminous-vivid-orange-color has-pale-ocean-gradient-background has-text-color has-background has-link-color wp-elements-123eed1fda1b03aa2fb6a86c24d9cedb\">CREATE USER '\u7528\u6237\u540d'@'\u4e3b\u673a' IDENTIFIED BY '\u5bc6\u7801';  -- \u4f8b\u5982\uff1a'test'@'localhost'\u2022:ml-citation{ref=\"5,7\" data=\"citationList\"}<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u200c\u6388\u4e88\u6743\u9650\u200c<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><\/pre>\n\n\n\n<pre class=\"wp-block-preformatted has-luminous-vivid-orange-color has-pale-ocean-gradient-background has-text-color has-background has-link-color wp-elements-3e1a0915905049af58c302d1deca673b\">GRANT SELECT, INSERT ON \u6570\u636e\u5e93.\u8868 TO '\u7528\u6237'@'\u4e3b\u673a';  -- \u6388\u4e88\u6307\u5b9a\u64cd\u4f5c\u6743\u9650\u2022:ml-citation{ref=\"5,6\" data=\"citationList\"}  <br><br>GRANT ALL PRIVILEGES ON *.* TO '\u7528\u6237'@'\u4e3b\u673a';       -- \u6388\u4e88\u5168\u5c40\u6743\u9650\u2022:ml-citation{ref=\"5,6\" data=\"citationList\"}<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u200c\u64a4\u9500\u6743\u9650\u200c<\/p>\n\n\n\n<pre class=\"wp-block-preformatted has-luminous-vivid-orange-color has-pale-ocean-gradient-background has-text-color has-background has-link-color wp-elements-52d8c42fb186d8ddf80e4b73b11becf6\">REVOKE SELECT ON \u6570\u636e\u5e93.\u8868 FROM '\u7528\u6237'@'\u4e3b\u673a';  -- \u64a4\u9500\u90e8\u5206\u6743\u9650\u2022:ml-citation{ref=\"5,7\" data=\"citationList\"}<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u200c\u4fee\u6539\u5bc6\u7801\u200c<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><\/pre>\n\n\n\n<pre class=\"wp-block-preformatted has-luminous-vivid-orange-color has-pale-ocean-gradient-background has-text-color has-background has-link-color wp-elements-b667f25489fc594ef5f92eb96b10243d\">SET PASSWORD FOR '\u7528\u6237'@'\u4e3b\u673a' = PASSWORD('\u65b0\u5bc6\u7801');  -- \u5bc6\u7801\u52a0\u5bc6\u5b58\u50a8\u2022:ml-citation{ref=\"5,7\" data=\"citationList\"}<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u200c\u67e5\u770b\u6743\u9650\u200c<\/p>\n\n\n\n<pre class=\"wp-block-preformatted has-luminous-vivid-orange-color has-pale-ocean-gradient-background has-text-color has-background has-link-color wp-elements-ffd0c5a49fcf6af0b3c0cb98b98c54b3\">SHOW GRANTS FOR '\u7528\u6237'@'\u4e3b\u673a';  -- \u663e\u793a\u7528\u6237\u6743\u9650\u8be6\u60c5\u2022:ml-citation{ref=\"5,7\" data=\"citationList\"}<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u200c\u56db\u3001\u6ce8\u610f\u4e8b\u9879\u200c<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u200c\u6743\u9650\u751f\u6548\u200c\uff1a\u6240\u6709\u6743\u9650\u64cd\u4f5c\u540e\u9700\u6267\u884c FLUSH PRIVILEGES;\u200c45\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u200c\u5b89\u5168\u5efa\u8bae\u200c\uff1a\u8fdc\u7a0b\u8bbf\u95ee\u5efa\u8bae\u9650\u5236IP\u8303\u56f4\uff0c\u907f\u514d\u4f7f\u7528 % \u5f00\u653e\u6240\u6709IP\u200c\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u200c\u914d\u7f6e\u6587\u4ef6\u8def\u5f84\u200c\uff1a\u901a\u8fc7 find \/ -name my.cnf \u67e5\u627e\u914d\u7f6e\u6587\u4ef6\u4f4d\u7f6e\u200c\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u200c\u5de5\u5177\u63a8\u8350\u200c\uff1a\u4f7f\u7528 mysql_secure_installation \u811a\u672c\u5feb\u901f\u521d\u59cb\u5316\u5b89\u5168\u914d\u7f6e\u200c\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>MySQL \u6570\u636e\u5e93\u64cd\u4f5c\u547d\u4ee4\u6307\u5357\uff082025\u5e74\u6700\u65b0\uff09 \u200c\u4e00\u3001\u589e\u5220\u6539\u67e5 (CRUD) \u64cd\u4f5c\u200c \u200c\u6570\u636e\u63d2\u5165\u200c INSERT INTO \u8868\u540d (\u5b57\u6bb51, \u5b57\u6bb52) VALUES (\u503c1, \u503c2); &#8212; \u63d2\u5165\u6307\u5b9a\u5b57\u6bb5\u6570\u636e\u2022:ml-citation{ref=&#8221;1,2&#8243; data=&#8221;citationList&#8221;} INSERT INTO \u8868\u540d VALUES (\u503c1, \u503c2); &#8212; \u63d2\u5165\u5168\u5b57\u6bb5\u6570\u636e\u2022:ml-citation{ref=&#8221;1,2&#8243; data=&#8221;citationList&#8221;} \u2022\u6570\u636e\u5220\u9664\u2022 DELETE FROM \u8868\u540d WHERE \u6761\u4ef6; &#8212; \u5220\u9664\u7b26\u5408\u6761\u4ef6\u7684\u6570\u636e\u2022:ml-citation{ref=&#8221;1,2&#8243; data=&#8221;citationList&#8221;} \u200c\u6570\u636e\u4fee\u6539\u200c UPDATE \u8868\u540d SET \u5b57\u6bb51=\u65b0\u503c WHERE \u6761\u4ef6; &#8212; \u66f4\u65b0\u6307\u5b9a\u5b57\u6bb5\u6570\u636e\u2022:ml-citation{ref=&#8221;1,2&#8243; data=&#8221;citationList&#8221;} \u200c\u6570\u636e\u67e5\u8be2\u200c SELECT \u5b57\u6bb5\u5217\u8868 FROM \u8868\u540d WHERE \u6761\u4ef6; &#8212; \u57fa\u7840\u67e5\u8be2\u2022:ml-citation{ref=&#8221;1,2&#8243; data=&#8221;citationList&#8221;} &hellip; <\/p>\n","protected":false},"author":1,"featured_media":189,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[22],"tags":[21],"class_list":["post-168","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-mysql","tag-mysql"],"_links":{"self":[{"href":"https:\/\/www.zhangwk.cn\/index.php\/wp-json\/wp\/v2\/posts\/168","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.zhangwk.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.zhangwk.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.zhangwk.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.zhangwk.cn\/index.php\/wp-json\/wp\/v2\/comments?post=168"}],"version-history":[{"count":3,"href":"https:\/\/www.zhangwk.cn\/index.php\/wp-json\/wp\/v2\/posts\/168\/revisions"}],"predecessor-version":[{"id":171,"href":"https:\/\/www.zhangwk.cn\/index.php\/wp-json\/wp\/v2\/posts\/168\/revisions\/171"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.zhangwk.cn\/index.php\/wp-json\/wp\/v2\/media\/189"}],"wp:attachment":[{"href":"https:\/\/www.zhangwk.cn\/index.php\/wp-json\/wp\/v2\/media?parent=168"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.zhangwk.cn\/index.php\/wp-json\/wp\/v2\/categories?post=168"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.zhangwk.cn\/index.php\/wp-json\/wp\/v2\/tags?post=168"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}