{"id":76556,"date":"2024-10-16T07:47:16","date_gmt":"2024-10-15T23:47:16","guid":{"rendered":"https:\/\/server.hk\/cnblog\/76556\/"},"modified":"2024-10-16T07:47:16","modified_gmt":"2024-10-15T23:47:16","slug":"mysql%e6%95%b8%e6%93%9a%e5%ba%ab%e5%af%86%e7%a2%bc%e5%bf%98%e8%a8%98%e7%9a%84%e8%a7%a3%e6%b1%ba%e6%96%b9%e6%a1%88","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/76556\/","title":{"rendered":"MySQL\u6578\u64da\u5eab\u5bc6\u78bc\u5fd8\u8a18\u7684\u89e3\u6c7a\u65b9\u6848"},"content":{"rendered":"<h1 id=\"mysql%e6%95%b8%e6%93%9a%e5%ba%ab%e5%af%86%e7%a2%bc%e5%bf%98%e8%a8%98%e7%9a%84%e8%a7%a3%e6%b1%ba%e6%96%b9%e6%a1%88-VTEEnoeMpp\">MySQL\u6578\u64da\u5eab\u5bc6\u78bc\u5fd8\u8a18\u7684\u89e3\u6c7a\u65b9\u6848<\/h1>\n<p>\u5728\u65e5\u5e38\u7684\u6578\u64da\u5eab\u7ba1\u7406\u4e2d\uff0cMySQL\u4f5c\u70ba\u4e00\u500b\u5ee3\u6cdb\u4f7f\u7528\u7684\u95dc\u806f\u6578\u64da\u5eab\u7ba1\u7406\u7cfb\u7d71\uff0c\u7d93\u5e38\u88ab\u7528\u65bc\u5404\u7a2e\u61c9\u7528\u7a0b\u5e8f\u548c\u7db2\u7ad9\u3002\u7136\u800c\uff0c\u5fd8\u8a18MySQL\u6578\u64da\u5eab\u7684\u5bc6\u78bc\u662f\u4e00\u500b\u5e38\u898b\u7684\u554f\u984c\uff0c\u9019\u53ef\u80fd\u6703\u5c0e\u81f4\u7121\u6cd5\u8a2a\u554f\u6578\u64da\u5eab\uff0c\u9032\u800c\u5f71\u97ff\u696d\u52d9\u904b\u4f5c\u3002\u672c\u6587\u5c07\u63a2\u8a0e\u5e7e\u7a2e\u89e3\u6c7a\u65b9\u6848\uff0c\u5e6b\u52a9\u7528\u6236\u91cd\u7f6eMySQL\u6578\u64da\u5eab\u5bc6\u78bc\u3002<\/p>\n<h2 id=\"%e8%a7%a3%e6%b1%ba%e6%96%b9%e6%a1%88%e4%b8%80%ef%bc%9a%e4%bd%bf%e7%94%a8%e5%ae%89%e5%85%a8%e6%a8%a1%e5%bc%8f%e9%87%8d%e7%bd%ae%e5%af%86%e7%a2%bc-VTEEnoeMpp\">\u89e3\u6c7a\u65b9\u6848\u4e00\uff1a\u4f7f\u7528\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>\u9996\u5148\uff0c\u505c\u6b62MySQL\u670d\u52d9\u3002\u60a8\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/li>\n<pre><code>sudo systemctl stop mysql<\/code><\/pre>\n<li>\u63a5\u8457\uff0c\u4ee5\u5b89\u5168\u6a21\u5f0f\u555f\u52d5MySQL\uff0c\u4e26\u8df3\u904e\u6388\u6b0a\u8868\uff1a<\/li>\n<pre><code>sudo mysqld_safe --skip-grant-tables &amp;<\/code><\/pre>\n<li>\u7136\u5f8c\uff0c\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\u66f4\u65b0\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>\u6700\u5f8c\uff0c\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=\"%e8%a7%a3%e6%b1%ba%e6%96%b9%e6%a1%88%e4%ba%8c%ef%bc%9a%e4%bd%bf%e7%94%a8%e9%85%8d%e7%bd%ae%e6%96%87%e4%bb%b6%e9%87%8d%e7%bd%ae%e5%af%86%e7%a2%bc-VTEEnoeMpp\">\u89e3\u6c7a\u65b9\u6848\u4e8c\uff1a\u4f7f\u7528\u914d\u7f6e\u6587\u4ef6\u91cd\u7f6e\u5bc6\u78bc<\/h2>\n<p>\u5982\u679c\u60a8\u7121\u6cd5\u4f7f\u7528\u5b89\u5168\u6a21\u5f0f\uff0c\u9084\u53ef\u4ee5\u901a\u904e\u4fee\u6539MySQL\u7684\u914d\u7f6e\u6587\u4ef6\u4f86\u91cd\u7f6e\u5bc6\u78bc\u3002\u9019\u7a2e\u65b9\u6cd5\u9069\u5408\u65bc\u7121\u6cd5\u9032\u5165MySQL\u7684\u60c5\u6cc1\u3002\u5177\u9ad4\u6b65\u9a5f\u5982\u4e0b\uff1a<\/p>\n<ol>\n<li>\u9996\u5148\uff0c\u627e\u5230MySQL\u7684\u914d\u7f6e\u6587\u4ef6\uff0c\u901a\u5e38\u4f4d\u65bc\/etc\/mysql\/my.cnf\u6216\/etc\/my.cnf\u3002<\/li>\n<li>\u5728\u914d\u7f6e\u6587\u4ef6\u4e2d\uff0c\u6dfb\u52a0\u4ee5\u4e0b\u884c\uff1a<\/li>\n<pre><code>[mysqld]<\/code><\/pre>\n<pre><code>skip-grant-tables<\/code><\/pre>\n<li>\u4fdd\u5b58\u4e26\u95dc\u9589\u6587\u4ef6\uff0c\u7136\u5f8c\u91cd\u555fMySQL\u670d\u52d9\uff1a<\/li>\n<pre><code>sudo systemctl restart mysql<\/code><\/pre>\n<li>\u63a5\u4e0b\u4f86\uff0c\u4f7f\u7528MySQL\u5ba2\u6236\u7aef\u9023\u63a5\u5230\u6578\u64da\u5eab\uff0c\u4e26\u91cd\u7f6e\u5bc6\u78bc\uff1a<\/li>\n<pre><code>mysql -u root<\/code><\/pre>\n<pre><code>FLUSH PRIVILEGES;<\/code><\/pre>\n<pre><code>ALTER USER 'root'@'localhost' IDENTIFIED BY '\u65b0\u5bc6\u78bc';<\/code><\/pre>\n<li>\u6700\u5f8c\uff0c\u522a\u9664\u914d\u7f6e\u6587\u4ef6\u4e2d\u7684skip-grant-tables\u884c\uff0c\u7136\u5f8c\u91cd\u555fMySQL\u670d\u52d9\u4ee5\u6062\u5fa9\u6b63\u5e38\u64cd\u4f5c\u3002<\/li>\n<\/ol>\n<h2 id=\"%e8%a7%a3%e6%b1%ba%e6%96%b9%e6%a1%88%e4%b8%89%ef%bc%9a%e4%bd%bf%e7%94%a8mysql%e7%9a%84%e5%91%bd%e4%bb%a4%e8%a1%8c%e5%b7%a5%e5%85%b7-VTEEnoeMpp\">\u89e3\u6c7a\u65b9\u6848\u4e09\uff1a\u4f7f\u7528MySQL\u7684\u547d\u4ee4\u884c\u5de5\u5177<\/h2>\n<p>\u5982\u679c\u60a8\u4f7f\u7528\u7684\u662f\u8f03\u65b0\u7248\u672c\u7684MySQL\uff0c\u5247\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u884c\u5de5\u5177\u4f86\u91cd\u7f6e\u5bc6\u78bc\uff1a<\/p>\n<ol>\n<li>\u9996\u5148\uff0c\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u9032\u5165MySQL\u547d\u4ee4\u884c\uff1a<\/li>\n<pre><code>mysqladmin -u root -p password '\u65b0\u5bc6\u78bc'<\/code><\/pre>\n<li>\u7cfb\u7d71\u6703\u63d0\u793a\u60a8\u8f38\u5165\u7576\u524d\u5bc6\u78bc\u3002\u5982\u679c\u60a8\u5fd8\u8a18\u4e86\u5bc6\u78bc\uff0c\u5247\u9700\u8981\u4f7f\u7528\u524d\u9762\u63d0\u5230\u7684\u5b89\u5168\u6a21\u5f0f\u6216\u914d\u7f6e\u6587\u4ef6\u65b9\u6cd5\u4f86\u91cd\u7f6e\u3002<\/li>\n<\/ol>\n<h2 id=\"%e7%b8%bd%e7%b5%90-VTEEnoeMpp\">\u7e3d\u7d50<\/h2>\n<p>\u5fd8\u8a18MySQL\u6578\u64da\u5eab\u5bc6\u78bc\u4e26\u4e0d\u7f55\u898b\uff0c\u4f46\u901a\u904e\u4e0a\u8ff0\u5e7e\u7a2e\u65b9\u6cd5\uff0c\u60a8\u53ef\u4ee5\u8f15\u9b06\u5730\u91cd\u7f6e\u5bc6\u78bc\uff0c\u6062\u5fa9\u5c0d\u6578\u64da\u5eab\u7684\u8a2a\u554f\u3002\u7121\u8ad6\u662f\u4f7f\u7528\u5b89\u5168\u6a21\u5f0f\u3001\u4fee\u6539\u914d\u7f6e\u6587\u4ef6\uff0c\u9084\u662f\u5229\u7528\u547d\u4ee4\u884c\u5de5\u5177\uff0c\u9019\u4e9b\u65b9\u6cd5\u90fd\u80fd\u6709\u6548\u89e3\u6c7a\u554f\u984c\u3002\u5c0d\u65bc\u9700\u8981\u7a69\u5b9a\u548c\u9ad8\u6548\u6578\u64da\u5eab\u7ba1\u7406\u7684\u7528\u6236\uff0c\u9078\u64c7\u5408\u9069\u7684 <a href=\"https:\/\/server.hk\">VPS<\/a> \u65b9\u6848\u4e5f\u662f\u81f3\u95dc\u91cd\u8981\u7684\uff0c\u9019\u6a23\u53ef\u4ee5\u78ba\u4fdd\u6578\u64da\u7684\u5b89\u5168\u6027\u548c\u53ef\u7528\u6027\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u627e\u56deMySQL\u6578\u64da\u5eab\u5bc6\u78bc\u7684\u7c21\u6613\u6b65\u9a5f\uff0c\u5e6b\u52a9\u60a8\u5feb\u901f\u91cd\u8a2d\u5bc6\u78bc\uff0c\u6062\u5fa9\u6578\u64da\u5eab\u8a2a\u554f\u6b0a\u9650\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-76556","post","type-post","status-publish","format-standard","hentry","category-database"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/76556","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=76556"}],"version-history":[{"count":1,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/76556\/revisions"}],"predecessor-version":[{"id":76557,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/76556\/revisions\/76557"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=76556"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=76556"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=76556"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}