{"id":76108,"date":"2024-10-16T03:55:15","date_gmt":"2024-10-15T19:55:15","guid":{"rendered":"https:\/\/server.hk\/cnblog\/76108\/"},"modified":"2024-10-16T03:55:15","modified_gmt":"2024-10-15T19:55:15","slug":"mysql%e5%af%86%e7%a2%bc%e6%81%a2%e5%be%a9%e5%92%8c%e4%bf%ae%e6%94%b9%e7%9a%84%e6%96%b9%e6%b3%95%e7%b8%bd%e7%b5%90%e7%af%87","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/76108\/","title":{"rendered":"MySQL\u5bc6\u78bc\u6062\u5fa9\u548c\u4fee\u6539\u7684\u65b9\u6cd5\u7e3d\u7d50\u7bc7"},"content":{"rendered":"<h1 id=\"mysql%e5%af%86%e7%a2%bc%e6%81%a2%e5%be%a9%e5%92%8c%e4%bf%ae%e6%94%b9%e7%9a%84%e6%96%b9%e6%b3%95%e7%b8%bd%e7%b5%90%e7%af%87-SCUWsgJJxt\">MySQL\u5bc6\u78bc\u6062\u5fa9\u548c\u4fee\u6539\u7684\u65b9\u6cd5\u7e3d\u7d50\u7bc7<\/h1>\n<p>\u5728\u6578\u64da\u5eab\u7ba1\u7406\u4e2d\uff0cMySQL\u662f\u4e00\u500b\u5ee3\u6cdb\u4f7f\u7528\u7684\u95dc\u806f\u6578\u64da\u5eab\u7ba1\u7406\u7cfb\u7d71\u3002\u96a8\u8457\u6578\u64da\u7684\u589e\u9577\u548c\u61c9\u7528\u7684\u8907\u96dc\u6027\uff0c\u7ba1\u7406\u6578\u64da\u5eab\u7684\u5b89\u5168\u6027\u548c\u53ef\u7528\u6027\u8b8a\u5f97\u81f3\u95dc\u91cd\u8981\u3002\u7279\u5225\u662f\u5bc6\u78bc\u7684\u7ba1\u7406\uff0c\u56e0\u70ba\u4e00\u65e6\u5fd8\u8a18\u6216\u4e1f\u5931\u5bc6\u78bc\uff0c\u5c07\u6703\u5f71\u97ff\u5230\u6578\u64da\u5eab\u7684\u8a2a\u554f\u3002\u672c\u6587\u5c07\u7e3d\u7d50\u5e7e\u7a2eMySQL\u5bc6\u78bc\u6062\u5fa9\u548c\u4fee\u6539\u7684\u65b9\u6cd5\uff0c\u5e6b\u52a9\u7528\u6236\u6709\u6548\u5730\u7ba1\u7406\u5176\u6578\u64da\u5eab\u5b89\u5168\u3002<\/p>\n<h2 id=\"1-%e4%bd%bf%e7%94%a8mysql%e7%9a%84%e5%ae%89%e5%85%a8%e6%a8%a1%e5%bc%8f%e9%87%8d%e7%bd%ae%e5%af%86%e7%a2%bc-SCUWsgJJxt\">1. \u4f7f\u7528MySQL\u7684\u5b89\u5168\u6a21\u5f0f\u91cd\u7f6e\u5bc6\u78bc<\/h2>\n<p>\u5982\u679c\u60a8\u5fd8\u8a18\u4e86MySQL\u7684\u5bc6\u78bc\uff0c\u53ef\u4ee5\u901a\u904e\u555f\u52d5MySQL\u7684\u5b89\u5168\u6a21\u5f0f\u4f86\u91cd\u7f6e\u5bc6\u78bc\u3002\u4ee5\u4e0b\u662f\u5177\u9ad4\u6b65\u9a5f\uff1a<\/p>\n<ol>\n<li>\u505c\u6b62MySQL\u670d\u52d9\uff1a<\/li>\n<pre><code>sudo systemctl stop mysql<\/code><\/pre>\n<li>\u4ee5\u5b89\u5168\u6a21\u5f0f\u555f\u52d5MySQL\uff1a<\/li>\n<pre><code>sudo mysqld_safe --skip-grant-tables &amp;<\/code><\/pre>\n<li>\u4f7f\u7528MySQL\u5ba2\u6236\u7aef\u9023\u63a5\u5230\u6578\u64da\u5eab\uff1a<\/li>\n<pre><code>mysql -u root<\/code><\/pre>\n<li>\u5728MySQL\u63d0\u793a\u7b26\u4e0b\uff0c\u57f7\u884c\u4ee5\u4e0b\u547d\u4ee4\u4f86\u4fee\u6539\u5bc6\u78bc\uff1a<\/li>\n<pre><code>FLUSH PRIVILEGES;<\/code><\/pre>\n<pre><code>ALTER USER 'root'@'localhost' IDENTIFIED BY '\u65b0\u5bc6\u78bc';<\/code><\/pre>\n<li>\u9000\u51faMySQL\u4e26\u91cd\u555f\u670d\u52d9\uff1a<\/li>\n<pre><code>exit<\/code><\/pre>\n<pre><code>sudo systemctl start mysql<\/code><\/pre>\n<\/ol>\n<h2 id=\"2-%e4%bd%bf%e7%94%a8mysql%e7%9a%84%e5%91%bd%e4%bb%a4%e8%a1%8c%e5%b7%a5%e5%85%b7%e4%bf%ae%e6%94%b9%e5%af%86%e7%a2%bc-SCUWsgJJxt\">2. \u4f7f\u7528MySQL\u7684\u547d\u4ee4\u884c\u5de5\u5177\u4fee\u6539\u5bc6\u78bc<\/h2>\n<p>\u5982\u679c\u60a8\u4ecd\u7136\u80fd\u5920\u8a2a\u554fMySQL\uff0c\u4f46\u60f3\u8981\u66f4\u6539\u5bc6\u78bc\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<pre><code>SET PASSWORD FOR '\u7528\u6236\u540d'@'\u4e3b\u6a5f' = PASSWORD('\u65b0\u5bc6\u78bc');<\/code><\/pre>\n<p>\u9019\u7a2e\u65b9\u6cd5\u9069\u5408\u65bc\u7528\u6236\u4ecd\u7136\u8a18\u5f97\u7576\u524d\u5bc6\u78bc\u7684\u60c5\u6cc1\u3002<\/p>\n<h2 id=\"3-%e4%bd%bf%e7%94%a8mysql%e7%9a%84%e9%85%8d%e7%bd%ae%e6%96%87%e4%bb%b6%e4%bf%ae%e6%94%b9%e5%af%86%e7%a2%bc-SCUWsgJJxt\">3. \u4f7f\u7528MySQL\u7684\u914d\u7f6e\u6587\u4ef6\u4fee\u6539\u5bc6\u78bc<\/h2>\n<p>\u5728\u67d0\u4e9b\u60c5\u6cc1\u4e0b\uff0c\u60a8\u53ef\u80fd\u9700\u8981\u76f4\u63a5\u4fee\u6539MySQL\u7684\u914d\u7f6e\u6587\u4ef6\u3002\u9019\u7a2e\u65b9\u6cd5\u901a\u5e38\u7528\u65bc\u7121\u6cd5\u901a\u904e\u5176\u4ed6\u65b9\u5f0f\u8a2a\u554f\u6578\u64da\u5eab\u7684\u60c5\u6cc1\u3002\u6b65\u9a5f\u5982\u4e0b\uff1a<\/p>\n<ol>\n<li>\u627e\u5230MySQL\u7684\u914d\u7f6e\u6587\u4ef6\uff08\u901a\u5e38\u662fmy.cnf\u6216my.ini\uff09\u3002<\/li>\n<li>\u5728\u914d\u7f6e\u6587\u4ef6\u4e2d\u6dfb\u52a0\u4ee5\u4e0b\u884c\uff1a<\/li>\n<pre><code>[mysqld]<\/code><\/pre>\n<pre><code>skip-grant-tables<\/code><\/pre>\n<li>\u91cd\u555fMySQL\u670d\u52d9\u3002<\/li>\n<li>\u6309\u7167\u7b2c\u4e00\u7a2e\u65b9\u6cd5\u4e2d\u7684\u6b65\u9a5f\u91cd\u7f6e\u5bc6\u78bc\u3002<\/li>\n<li>\u5b8c\u6210\u5f8c\uff0c\u8a18\u5f97\u522a\u9664\u914d\u7f6e\u6587\u4ef6\u4e2d\u7684skip-grant-tables\u884c\uff0c\u7136\u5f8c\u91cd\u555f\u670d\u52d9\u3002<\/li>\n<\/ol>\n<h2 id=\"4-%e4%bd%bf%e7%94%a8mysql-workbench%e4%bf%ae%e6%94%b9%e5%af%86%e7%a2%bc-SCUWsgJJxt\">4. \u4f7f\u7528MySQL Workbench\u4fee\u6539\u5bc6\u78bc<\/h2>\n<p>\u5982\u679c\u60a8\u66f4\u559c\u6b61\u5716\u5f62\u754c\u9762\uff0c\u53ef\u4ee5\u4f7f\u7528MySQL Workbench\u4f86\u4fee\u6539\u5bc6\u78bc\u3002\u6b65\u9a5f\u5982\u4e0b\uff1a<\/p>\n<ol>\n<li>\u6253\u958bMySQL Workbench\u4e26\u9023\u63a5\u5230\u6578\u64da\u5eab\u3002<\/li>\n<li>\u5728\u5de6\u5074\u7684\u5c0e\u822a\u6b04\u4e2d\uff0c\u53f3\u9375\u55ae\u64ca\u7528\u6236\u4e26\u9078\u64c7\u201c\u4fee\u6539\u7528\u6236\u201d\u3002<\/li>\n<li>\u5728\u5f48\u51fa\u7684\u7a97\u53e3\u4e2d\uff0c\u8f38\u5165\u65b0\u5bc6\u78bc\u4e26\u4fdd\u5b58\u66f4\u6539\u3002<\/li>\n<\/ol>\n<h2 id=\"5-%e9%a0%90%e9%98%b2%e6%8e%aa%e6%96%bd-SCUWsgJJxt\">5. \u9810\u9632\u63aa\u65bd<\/h2>\n<p>\u70ba\u4e86\u907f\u514d\u672a\u4f86\u51fa\u73fe\u5bc6\u78bc\u4e1f\u5931\u7684\u60c5\u6cc1\uff0c\u5efa\u8b70\u7528\u6236\u63a1\u53d6\u4ee5\u4e0b\u9810\u9632\u63aa\u65bd\uff1a<\/p>\n<ul>\n<li>\u5b9a\u671f\u5099\u4efd\u6578\u64da\u5eab\u3002<\/li>\n<li>\u4f7f\u7528\u5bc6\u78bc\u7ba1\u7406\u5de5\u5177\u4f86\u8a18\u9304\u548c\u7ba1\u7406\u5bc6\u78bc\u3002<\/li>\n<li>\u8a2d\u7f6e\u5b89\u5168\u554f\u984c\u6216\u96d9\u91cd\u8eab\u4efd\u9a57\u8b49\u4ee5\u589e\u5f37\u5b89\u5168\u6027\u3002<\/li>\n<\/ul>\n<h2 id=\"%e7%b8%bd%e7%b5%90-SCUWsgJJxt\">\u7e3d\u7d50<\/h2>\n<p>MySQL\u5bc6\u78bc\u7684\u6062\u5fa9\u548c\u4fee\u6539\u662f\u6578\u64da\u5eab\u7ba1\u7406\u4e2d\u4e0d\u53ef\u6216\u7f3a\u7684\u4e00\u90e8\u5206\u3002\u7121\u8ad6\u662f\u901a\u904e\u5b89\u5168\u6a21\u5f0f\u3001\u547d\u4ee4\u884c\u5de5\u5177\u3001\u914d\u7f6e\u6587\u4ef6\u9084\u662f\u5716\u5f62\u754c\u9762\uff0c\u4e86\u89e3\u9019\u4e9b\u65b9\u6cd5\u90fd\u80fd\u5e6b\u52a9\u7528\u6236\u5728\u9047\u5230\u554f\u984c\u6642\u8fc5\u901f\u89e3\u6c7a\u3002\u70ba\u4e86\u78ba\u4fdd\u6578\u64da\u7684\u5b89\u5168\u6027\uff0c\u5efa\u8b70\u7528\u6236\u5b9a\u671f\u6aa2\u67e5\u548c\u66f4\u65b0\u5bc6\u78bc\uff0c\u4e26\u63a1\u53d6\u5fc5\u8981\u7684\u9810\u9632\u63aa\u65bd\u3002\u82e5\u60a8\u9700\u8981\u9032\u4e00\u6b65\u7684\u652f\u6301\u6216\u670d\u52d9\uff0c\u8acb\u8a2a\u554f\u6211\u5011\u7684\u7db2\u7ad9\u4e86\u89e3\u66f4\u591a\u95dc\u65bc<a href=\"https:\/\/server.hk\">\u9999\u6e2fVPS<\/a>\u548c<a href=\"https:\/\/server.hk\">\u96f2\u4f3a\u670d\u5668<\/a>\u7684\u8cc7\u8a0a\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u7e3d\u7d50MySQL\u5bc6\u78bc\u6062\u5fa9\u548c\u4fee\u6539\u7684\u65b9\u6cd5\uff0c\u63d0\u4f9b\u5be6\u7528\u6b65\u9a5f\u548c\u6280\u5de7\uff0c\u5e6b\u52a9\u7528\u6236\u8f15\u9b06\u89e3\u6c7a\u5bc6\u78bc\u554f\u984c\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-76108","post","type-post","status-publish","format-standard","hentry","category-database"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/76108","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=76108"}],"version-history":[{"count":1,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/76108\/revisions"}],"predecessor-version":[{"id":76109,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/76108\/revisions\/76109"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=76108"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=76108"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=76108"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}