{"id":179634,"date":"2024-11-09T03:31:22","date_gmt":"2024-11-08T19:31:22","guid":{"rendered":"https:\/\/server.hk\/cnblog\/179634\/"},"modified":"2024-11-09T03:31:24","modified_gmt":"2024-11-08T19:31:24","slug":"%e5%a6%82%e4%bd%95%e5%9c%a8-mysql-%e4%b8%ad%e6%9b%b4%e6%94%b9%e6%95%b8%e6%93%9a%e5%ba%ab%e5%af%86%e7%a2%bc-sql-%e7%9a%84%e6%ad%a5%e9%a9%9f-mysql-%e6%9b%b4%e6%94%b9%e6%95%b8%e6%93%9a%e5%ba%ab%e5%af%86","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/179634\/","title":{"rendered":"\u5982\u4f55\u5728 MySQL \u4e2d\u66f4\u6539\u6578\u64da\u5eab\u5bc6\u78bc SQL \u7684\u6b65\u9a5f (mysql \u66f4\u6539\u6578\u64da\u5eab\u5bc6\u78bc sql)"},"content":{"rendered":"<h1 id=\"%e5%a6%82%e4%bd%95%e5%9c%a8-mysql-%e4%b8%ad%e6%9b%b4%e6%94%b9%e6%95%b8%e6%93%9a%e5%ba%ab%e5%af%86%e7%a2%bc-sql-%e7%9a%84%e6%ad%a5%e9%a9%9f-MhBmgCktnr\">\u5982\u4f55\u5728 MySQL \u4e2d\u66f4\u6539\u6578\u64da\u5eab\u5bc6\u78bc SQL \u7684\u6b65\u9a5f<\/h1>\n<p>\u5728\u7ba1\u7406\u6578\u64da\u5eab\u6642\uff0c\u78ba\u4fdd\u6578\u64da\u5eab\u7684\u5b89\u5168\u6027\u662f\u81f3\u95dc\u91cd\u8981\u7684\u3002\u66f4\u6539 MySQL \u6578\u64da\u5eab\u7684\u5bc6\u78bc\u662f\u4e00\u500b\u57fa\u672c\u7684\u5b89\u5168\u63aa\u65bd\uff0c\u5c24\u5176\u662f\u5728\u61f7\u7591\u5bc6\u78bc\u53ef\u80fd\u88ab\u6d29\u9732\u6216\u9700\u8981\u5b9a\u671f\u66f4\u65b0\u7684\u60c5\u6cc1\u4e0b\u3002\u672c\u6587\u5c07\u8a73\u7d30\u4ecb\u7d39\u5982\u4f55\u5728 MySQL \u4e2d\u66f4\u6539\u6578\u64da\u5eab\u5bc6\u78bc\u7684\u6b65\u9a5f\uff0c\u4e26\u63d0\u4f9b\u76f8\u95dc\u7684 SQL \u8a9e\u53e5\u793a\u4f8b\u3002<\/p>\n<h2 id=\"%e6%ad%a5%e9%a9%9f%e4%b8%80%ef%bc%9a%e7%99%bb%e9%8c%84-mysql-MhBmgCktnr\">\u6b65\u9a5f\u4e00\uff1a\u767b\u9304 MySQL<\/h2>\n<p>\u9996\u5148\uff0c\u60a8\u9700\u8981\u4f7f\u7528\u5177\u6709\u8db3\u5920\u6b0a\u9650\u7684\u7528\u6236\u767b\u9304\u5230 MySQL\u3002\u901a\u5e38\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u5728\u7d42\u7aef\u4e2d\u767b\u9304\uff1a<\/p>\n<pre><code>mysql -u username -p<\/code><\/pre>\n<p>\u5728\u9019\u88e1\uff0c\u5c07 <code>username<\/code> \u66ff\u63db\u70ba\u60a8\u7684 MySQL \u7528\u6236\u540d\u3002\u7cfb\u7d71\u6703\u63d0\u793a\u60a8\u8f38\u5165\u5bc6\u78bc\u3002<\/p>\n<h2 id=\"%e6%ad%a5%e9%a9%9f%e4%ba%8c%ef%bc%9a%e9%81%b8%e6%93%87%e8%a6%81%e6%9b%b4%e6%94%b9%e5%af%86%e7%a2%bc%e7%9a%84%e7%94%a8%e6%88%b6-MhBmgCktnr\">\u6b65\u9a5f\u4e8c\uff1a\u9078\u64c7\u8981\u66f4\u6539\u5bc6\u78bc\u7684\u7528\u6236<\/h2>\n<p>\u5728 MySQL \u4e2d\uff0c\u60a8\u53ef\u4ee5\u70ba\u4e0d\u540c\u7684\u7528\u6236\u8a2d\u7f6e\u4e0d\u540c\u7684\u5bc6\u78bc\u3002\u8981\u67e5\u770b\u7576\u524d\u7528\u6236\uff0c\u60a8\u53ef\u4ee5\u57f7\u884c\u4ee5\u4e0b SQL \u67e5\u8a62\uff1a<\/p>\n<pre><code>SELECT User, Host FROM mysql.user;<\/code><\/pre>\n<p>\u9019\u5c07\u986f\u793a\u6240\u6709\u7528\u6236\u53ca\u5176\u4e3b\u6a5f\u4fe1\u606f\u3002\u78ba\u5b9a\u60a8\u8981\u66f4\u6539\u5bc6\u78bc\u7684\u7528\u6236\u3002<\/p>\n<h2 id=\"%e6%ad%a5%e9%a9%9f%e4%b8%89%ef%bc%9a%e6%9b%b4%e6%94%b9%e7%94%a8%e6%88%b6%e5%af%86%e7%a2%bc-MhBmgCktnr\">\u6b65\u9a5f\u4e09\uff1a\u66f4\u6539\u7528\u6236\u5bc6\u78bc<\/h2>\n<p>\u5728 MySQL 5.7 \u53ca\u4ee5\u4e0a\u7248\u672c\u4e2d\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u4f86\u66f4\u6539\u7528\u6236\u7684\u5bc6\u78bc\uff1a<\/p>\n<pre><code>ALTER USER 'username'@'host' IDENTIFIED BY 'new_password';<\/code><\/pre>\n<p>\u5728\u9019\u88e1\uff0c\u5c07 <code>username<\/code> \u66ff\u63db\u70ba\u7528\u6236\u540d\uff0c<code>host<\/code> \u66ff\u63db\u70ba\u7528\u6236\u7684\u4e3b\u6a5f\uff08\u4f8b\u5982 <code>localhost<\/code>\uff09\uff0c\u4e26\u5c07 <code>new_password<\/code> \u66ff\u63db\u70ba\u60a8\u5e0c\u671b\u8a2d\u7f6e\u7684\u65b0\u5bc6\u78bc\u3002<\/p>\n<p>\u5982\u679c\u60a8\u4f7f\u7528\u7684\u662f MySQL 5.6 \u6216\u66f4\u65e9\u7248\u672c\uff0c\u5247\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<pre><code>SET PASSWORD FOR 'username'@'host' = PASSWORD('new_password');<\/code><\/pre>\n<h2 id=\"%e6%ad%a5%e9%a9%9f%e5%9b%9b%ef%bc%9a%e5%88%b7%e6%96%b0%e6%ac%8a%e9%99%90-MhBmgCktnr\">\u6b65\u9a5f\u56db\uff1a\u5237\u65b0\u6b0a\u9650<\/h2>\n<p>\u66f4\u6539\u5bc6\u78bc\u5f8c\uff0c\u5efa\u8b70\u5237\u65b0 MySQL \u7684\u6b0a\u9650\uff0c\u4ee5\u78ba\u4fdd\u66f4\u6539\u7acb\u5373\u751f\u6548\u3002\u60a8\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u4f86\u5237\u65b0\u6b0a\u9650\uff1a<\/p>\n<pre><code>FLUSH PRIVILEGES;<\/code><\/pre>\n<h2 id=\"%e6%ad%a5%e9%a9%9f%e4%ba%94%ef%bc%9a%e9%a9%97%e8%ad%89%e5%af%86%e7%a2%bc%e6%9b%b4%e6%94%b9-MhBmgCktnr\">\u6b65\u9a5f\u4e94\uff1a\u9a57\u8b49\u5bc6\u78bc\u66f4\u6539<\/h2>\n<p>\u6700\u5f8c\uff0c\u60a8\u53ef\u4ee5\u5617\u8a66\u4f7f\u7528\u65b0\u5bc6\u78bc\u767b\u9304 MySQL\uff0c\u4ee5\u78ba\u4fdd\u5bc6\u78bc\u66f4\u6539\u6210\u529f\u3002\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<pre><code>mysql -u username -p<\/code><\/pre>\n<p>\u8f38\u5165\u65b0\u5bc6\u78bc\u5f8c\uff0c\u60a8\u61c9\u8a72\u80fd\u5920\u6210\u529f\u767b\u9304\u3002<\/p>\n<h2 id=\"%e6%b3%a8%e6%84%8f%e4%ba%8b%e9%a0%85-MhBmgCktnr\">\u6ce8\u610f\u4e8b\u9805<\/h2>\n<ul>\n<li>\u78ba\u4fdd\u65b0\u5bc6\u78bc\u7684\u5f37\u5ea6\uff0c\u5efa\u8b70\u4f7f\u7528\u5305\u542b\u5b57\u6bcd\u3001\u6578\u5b57\u548c\u7279\u6b8a\u5b57\u7b26\u7684\u7d44\u5408\u3002<\/li>\n<li>\u5b9a\u671f\u66f4\u6539\u5bc6\u78bc\u4ee5\u63d0\u9ad8\u5b89\u5168\u6027\u3002<\/li>\n<li>\u5728\u66f4\u6539\u5bc6\u78bc\u4e4b\u524d\uff0c\u8acb\u78ba\u4fdd\u60a8\u6709\u6b0a\u9650\u9032\u884c\u6b64\u64cd\u4f5c\u3002<\/li>\n<\/ul>\n<h2 id=\"%e7%b8%bd%e7%b5%90-MhBmgCktnr\">\u7e3d\u7d50<\/h2>\n<p>\u5728 MySQL \u4e2d\u66f4\u6539\u6578\u64da\u5eab\u5bc6\u78bc\u662f\u4e00\u500b\u7c21\u55ae\u4f46\u91cd\u8981\u7684\u904e\u7a0b\uff0c\u80fd\u5920\u6709\u6548\u63d0\u9ad8\u6578\u64da\u5eab\u7684\u5b89\u5168\u6027\u3002\u901a\u904e\u9075\u5faa\u4e0a\u8ff0\u6b65\u9a5f\uff0c\u60a8\u53ef\u4ee5\u8f15\u9b06\u5730\u66f4\u65b0\u7528\u6236\u5bc6\u78bc\uff0c\u78ba\u4fdd\u6578\u64da\u7684\u5b89\u5168\u6027\u3002\u5982\u679c\u60a8\u9700\u8981\u66f4\u9ad8\u6548\u7684\u6578\u64da\u5eab\u7ba1\u7406\u89e3\u6c7a\u65b9\u6848\uff0c\u8003\u616e\u4f7f\u7528\u6211\u5011\u7684 <a href=\"https:\/\/server.hk\">\u9999\u6e2f VPS<\/a> \u670d\u52d9\uff0c\u63d0\u4f9b\u7a69\u5b9a\u548c\u5b89\u5168\u7684\u6578\u64da\u5eab\u74b0\u5883\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5b78\u7fd2\u5982\u4f55\u5728 MySQL \u4e2d\u66f4\u6539\u6578\u64da\u5eab\u5bc6\u78bc\u7684\u6b65\u9a5f\uff0c\u78ba\u4fdd\u6578\u64da\u5b89\u5168\uff0c\u7c21\u55ae\u6613\u61c2\u7684 SQL \u6307\u4ee4\u6559\u5b78\u3002<\/p>\n","protected":false},"author":0,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[101],"tags":[],"class_list":["post-179634","post","type-post","status-publish","format-standard","hentry","category-database"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/179634","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/types\/post"}],"replies":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/comments?post=179634"}],"version-history":[{"count":1,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/179634\/revisions"}],"predecessor-version":[{"id":179635,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/179634\/revisions\/179635"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=179634"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=179634"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=179634"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}