{"id":76558,"date":"2024-10-16T07:48:15","date_gmt":"2024-10-15T23:48:15","guid":{"rendered":"https:\/\/server.hk\/cnblog\/76558\/"},"modified":"2024-10-16T07:48:15","modified_gmt":"2024-10-15T23:48:15","slug":"mysql%e6%95%b8%e6%93%9a%e5%ba%ab%e5%af%86%e7%a2%bc%e5%bf%98%e8%a8%98%e4%ba%86%ef%bc%8c%e6%80%8e%e9%ba%bc%e8%be%a6%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/76558\/","title":{"rendered":"MySQL\u6578\u64da\u5eab\u5bc6\u78bc\u5fd8\u8a18\u4e86\uff0c\u600e\u9ebc\u8fa6\uff1f"},"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%e4%ba%86%ef%bc%8c%e6%80%8e%e9%ba%bc%e8%be%a6%ef%bc%9f-gSpuCqcmdb\">MySQL\u6578\u64da\u5eab\u5bc6\u78bc\u5fd8\u8a18\u4e86\uff0c\u600e\u9ebc\u8fa6\uff1f<\/h1>\n<p>\u5728\u4f7f\u7528MySQL\u6578\u64da\u5eab\u7684\u904e\u7a0b\u4e2d\uff0c\u5fd8\u8a18\u6578\u64da\u5eab\u5bc6\u78bc\u662f\u4e00\u500b\u5e38\u898b\u7684\u554f\u984c\u3002\u9019\u4e0d\u50c5\u6703\u5f71\u97ff\u5230\u6578\u64da\u7684\u7ba1\u7406\uff0c\u9084\u53ef\u80fd\u5c0e\u81f4\u61c9\u7528\u7a0b\u5e8f\u7121\u6cd5\u6b63\u5e38\u904b\u884c\u3002\u672c\u6587\u5c07\u4ecb\u7d39\u5e7e\u7a2e\u91cd\u7f6eMySQL\u6578\u64da\u5eab\u5bc6\u78bc\u7684\u65b9\u6cd5\uff0c\u5e6b\u52a9\u7528\u6236\u5feb\u901f\u6062\u5fa9\u5c0d\u6578\u64da\u5eab\u7684\u8a2a\u554f\u3002<\/p>\n<h2 id=\"%e6%96%b9%e6%b3%95%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-gSpuCqcmdb\">\u65b9\u6cd5\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\u5b89\u5168\u6a21\u5f0f\u4f86\u91cd\u7f6e\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=\"%e6%96%b9%e6%b3%95%e4%ba%8c%ef%bc%9a%e4%bd%bf%e7%94%a8mysql%e9%85%8d%e7%bd%ae%e6%96%87%e4%bb%b6-gSpuCqcmdb\">\u65b9\u6cd5\u4e8c\uff1a\u4f7f\u7528MySQL\u914d\u7f6e\u6587\u4ef6<\/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\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\uff1a<\/li>\n<pre><code>mysql -u root<\/code><\/pre>\n<li>\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\u8a18\u5f97\u522a\u9664\u914d\u7f6e\u6587\u4ef6\u4e2d\u6dfb\u52a0\u7684skip-grant-tables\u884c\uff0c\u7136\u5f8c\u91cd\u555fMySQL\u670d\u52d9\u3002<\/li>\n<\/ol>\n<h2 id=\"%e6%96%b9%e6%b3%95%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-gSpuCqcmdb\">\u65b9\u6cd5\u4e09\uff1a\u4f7f\u7528MySQL\u7684\u547d\u4ee4\u884c\u5de5\u5177<\/h2>\n<p>\u5982\u679c\u60a8\u6709\u5176\u4ed6\u7528\u6236\u7684\u8a2a\u554f\u6b0a\u9650\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u4f86\u91cd\u7f6e\u5bc6\u78bc\uff1a<\/p>\n<pre><code>SET PASSWORD FOR '\u7528\u6236\u540d'@'localhost' = PASSWORD('\u65b0\u5bc6\u78bc');<\/code><\/pre>\n<p>\u9019\u7a2e\u65b9\u6cd5\u9700\u8981\u60a8\u5df2\u7d93\u80fd\u5920\u4ee5\u5176\u4ed6\u7528\u6236\u8eab\u4efd\u767b\u9304\u5230MySQL\u3002<\/p>\n<h2 id=\"%e7%b8%bd%e7%b5%90-gSpuCqcmdb\">\u7e3d\u7d50<\/h2>\n<p>\u5fd8\u8a18MySQL\u6578\u64da\u5eab\u5bc6\u78bc\u4e26\u4e0d\u6703\u9020\u6210\u7121\u6cd5\u633d\u56de\u7684\u640d\u5931\uff0c\u901a\u904e\u4e0a\u8ff0\u5e7e\u7a2e\u65b9\u6cd5\uff0c\u60a8\u53ef\u4ee5\u8f15\u9b06\u5730\u91cd\u7f6e\u5bc6\u78bc\u4e26\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\u901a\u904e\u5176\u4ed6\u7528\u6236\u7684\u6b0a\u9650\uff0c\u9019\u4e9b\u65b9\u6cd5\u90fd\u80fd\u6709\u6548\u89e3\u6c7a\u554f\u984c\u3002<\/p>\n<p>\u5982\u679c\u60a8\u5728\u5c0b\u627e\u7a69\u5b9a\u7684\u6578\u64da\u5eab\u89e3\u6c7a\u65b9\u6848\uff0c\u8003\u616e\u4f7f\u7528<a href=\"https:\/\/server.hk\">\u9999\u6e2fVPS<\/a>\u6216<a href=\"https:\/\/server.hk\">\u9999\u6e2f\u4f3a\u670d\u5668<\/a>\uff0c\u4ee5\u78ba\u4fdd\u60a8\u7684\u6578\u64da\u5b89\u5168\u548c\u9ad8\u6548\u904b\u884c\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5fd8\u8a18MySQL\u6578\u64da\u5eab\u5bc6\u78bc\uff1f\u4e86\u89e3\u91cd\u7f6e\u5bc6\u78bc\u7684\u6b65\u9a5f\uff0c\u8f15\u9b06\u6062\u5fa9\u8a2a\u554f\u6578\u64da\u5eab\uff0c\u78ba\u4fdd\u6578\u64da\u5b89\u5168\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-76558","post","type-post","status-publish","format-standard","hentry","category-database"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/76558","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=76558"}],"version-history":[{"count":1,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/76558\/revisions"}],"predecessor-version":[{"id":76559,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/76558\/revisions\/76559"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=76558"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=76558"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=76558"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}