{"id":190204,"date":"2024-11-12T10:38:22","date_gmt":"2024-11-12T02:38:22","guid":{"rendered":"https:\/\/server.hk\/cnblog\/190204\/"},"modified":"2024-11-12T10:38:23","modified_gmt":"2024-11-12T02:38:23","slug":"%e5%bf%98%e8%a8%98mysql%e5%af%86%e7%a2%bc%e6%80%8e%e9%ba%bc%e8%be%a6%ef%bc%9f%e6%95%99%e4%bd%a0%e7%b0%a1%e5%96%ae%e6%9f%a5%e6%89%be%e6%96%b9%e6%b3%95-mysql%e6%95%b8%e6%93%9a%e5%ba%ab%e6%9f%a5","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/190204\/","title":{"rendered":"\u5fd8\u8a18mysql\u5bc6\u78bc\u600e\u9ebc\u8fa6\uff1f\u6559\u4f60\u7c21\u55ae\u67e5\u627e\u65b9\u6cd5 (mysql\u6578\u64da\u5eab\u67e5\u627e\u5bc6\u78bc\u5fd8\u8a18\u4e86)"},"content":{"rendered":"<h1 id=\"%e5%bf%98%e8%a8%98mysql%e5%af%86%e7%a2%bc%e6%80%8e%e9%ba%bc%e8%be%a6%ef%bc%9f%e6%95%99%e4%bd%a0%e7%b0%a1%e5%96%ae%e6%9f%a5%e6%89%be%e6%96%b9%e6%b3%95-AjKNHSglSO\">\u5fd8\u8a18MySQL\u5bc6\u78bc\u600e\u9ebc\u8fa6\uff1f\u6559\u4f60\u7c21\u55ae\u67e5\u627e\u65b9\u6cd5<\/h1>\n<p>\u5728\u4f7f\u7528MySQL\u6578\u64da\u5eab\u7684\u904e\u7a0b\u4e2d\uff0c\u5fd8\u8a18\u5bc6\u78bc\u662f\u4e00\u500b\u5e38\u898b\u7684\u554f\u984c\u3002\u7121\u8ad6\u662f\u56e0\u70ba\u9577\u6642\u9593\u672a\u4f7f\u7528\uff0c\u9084\u662f\u56e0\u70ba\u5bc6\u78bc\u904e\u65bc\u8907\u96dc\uff0c\u5c0e\u81f4\u7121\u6cd5\u8a18\u8d77\u4f86\uff0c\u9019\u90fd\u53ef\u80fd\u5f71\u97ff\u5230\u6578\u64da\u5eab\u7684\u6b63\u5e38\u904b\u884c\u3002\u672c\u6587\u5c07\u4ecb\u7d39\u5e7e\u7a2e\u7c21\u55ae\u7684\u65b9\u6cd5\u4f86\u91cd\u7f6e\u6216\u67e5\u627eMySQL\u5bc6\u78bc\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-AjKNHSglSO\">\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\u4ee5\u4e0b\u6b65\u9a5f\u9032\u5165\u5b89\u5168\u6a21\u5f0f\u4f86\u91cd\u7f6e\u5bc6\u78bc\uff1a<\/p>\n<ol>\n<li>\u9996\u5148\uff0c\u505c\u6b62MySQL\u670d\u52d9\u3002\u60a8\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u4f86\u505c\u6b62\u670d\u52d9\uff1a<\/li>\n<pre><code>sudo systemctl stop mysql<\/code><\/pre>\n<li>\u63a5\u4e0b\u4f86\uff0c\u4ee5\u5b89\u5168\u6a21\u5f0f\u555f\u52d5MySQL\uff0c\u9019\u6a23\u53ef\u4ee5\u8df3\u904e\u6388\u6b0a\u8868\u7684\u6aa2\u67e5\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>\u9032\u5165MySQL\u5f8c\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%a8%e9%85%8d%e7%bd%ae%e6%96%87%e4%bb%b6%e6%9f%a5%e6%89%be%e5%af%86%e7%a2%bc-AjKNHSglSO\">\u65b9\u6cd5\u4e8c\uff1a\u4f7f\u7528\u914d\u7f6e\u6587\u4ef6\u67e5\u627e\u5bc6\u78bc<\/h2>\n<p>\u5982\u679c\u60a8\u5728\u5b89\u88ddMySQL\u6642\u5c07\u5bc6\u78bc\u5beb\u5165\u4e86\u914d\u7f6e\u6587\u4ef6\u4e2d\uff0c\u53ef\u4ee5\u901a\u904e\u67e5\u627e\u8a72\u6587\u4ef6\u4f86\u627e\u56de\u5bc6\u78bc\u3002\u901a\u5e38\uff0cMySQL\u7684\u914d\u7f6e\u6587\u4ef6\u4f4d\u65bc\u4ee5\u4e0b\u8def\u5f91\uff1a<\/p>\n<pre><code>\/etc\/mysql\/my.cnf<\/code><\/pre>\n<p>\u60a8\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u67e5\u770b\u8a72\u6587\u4ef6\uff1a<\/p>\n<pre><code>cat \/etc\/mysql\/my.cnf<\/code><\/pre>\n<p>\u5728\u6587\u4ef6\u4e2d\uff0c\u67e5\u627e\u4ee5\u4e0b\u884c\uff1a<\/p>\n<pre><code>[client]<\/code><\/pre>\n<p>\u5982\u679c\u6709\u8a2d\u7f6e\u5bc6\u78bc\uff0c\u60a8\u6703\u770b\u5230\u985e\u4f3c\u65bc\u4ee5\u4e0b\u7684\u5167\u5bb9\uff1a<\/p>\n<pre><code>password=\u60a8\u7684\u5bc6\u78bc<\/code><\/pre>\n<h2 id=\"%e6%96%b9%e6%b3%95%e4%b8%89%ef%bc%9a%e9%87%8d%e6%96%b0%e5%ae%89%e8%a3%9dmysql-AjKNHSglSO\">\u65b9\u6cd5\u4e09\uff1a\u91cd\u65b0\u5b89\u88ddMySQL<\/h2>\n<p>\u5982\u679c\u4ee5\u4e0a\u65b9\u6cd5\u90fd\u7121\u6cd5\u89e3\u6c7a\u554f\u984c\uff0c\u60a8\u53ef\u4ee5\u8003\u616e\u91cd\u65b0\u5b89\u88ddMySQL\u3002\u5728\u91cd\u65b0\u5b89\u88dd\u4e4b\u524d\uff0c\u8acb\u52d9\u5fc5\u5099\u4efd\u60a8\u7684\u6578\u64da\u5eab\uff0c\u4ee5\u514d\u6578\u64da\u4e1f\u5931\u3002\u91cd\u65b0\u5b89\u88dd\u7684\u6b65\u9a5f\u5982\u4e0b\uff1a<\/p>\n<ol>\n<li>\u9996\u5148\uff0c\u5378\u8f09\u7576\u524d\u7684MySQL\u7248\u672c\uff1a<\/li>\n<pre><code>sudo apt-get remove --purge mysql-server mysql-client mysql-common mysql-server-core-* mysql-client-core-*<\/code><\/pre>\n<li>\u7136\u5f8c\uff0c\u6e05\u7406\u7cfb\u7d71\u4e2d\u7684\u6240\u6709MySQL\u6587\u4ef6\uff1a<\/li>\n<pre><code>sudo rm -rf \/etc\/mysql \/var\/lib\/mysql<\/code><\/pre>\n<li>\u63a5\u4e0b\u4f86\uff0c\u91cd\u65b0\u5b89\u88ddMySQL\uff1a<\/li>\n<pre><code>sudo apt-get install mysql-server<\/code><\/pre>\n<li>\u5728\u5b89\u88dd\u904e\u7a0b\u4e2d\uff0c\u7cfb\u7d71\u6703\u63d0\u793a\u60a8\u8a2d\u7f6e\u65b0\u7684root\u5bc6\u78bc\u3002<\/li>\n<\/ol>\n<h2 id=\"%e7%b8%bd%e7%b5%90-AjKNHSglSO\">\u7e3d\u7d50<\/h2>\n<p>\u5fd8\u8a18MySQL\u5bc6\u78bc\u4e26\u4e0d\u9700\u8981\u904e\u65bc\u64d4\u5fc3\uff0c\u901a\u904e\u4e0a\u8ff0\u5e7e\u7a2e\u65b9\u6cd5\uff0c\u60a8\u53ef\u4ee5\u8f15\u9b06\u5730\u91cd\u7f6e\u6216\u67e5\u627e\u5bc6\u78bc\u3002\u7121\u8ad6\u662f\u4f7f\u7528\u5b89\u5168\u6a21\u5f0f\u3001\u67e5\u627e\u914d\u7f6e\u6587\u4ef6\uff0c\u9084\u662f\u91cd\u65b0\u5b89\u88ddMySQL\uff0c\u9019\u4e9b\u65b9\u6cd5\u90fd\u80fd\u5e6b\u52a9\u60a8\u6062\u5fa9\u5c0d\u6578\u64da\u5eab\u7684\u8a2a\u554f\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> \u670d\u52d9\u53ef\u4ee5\u63d0\u4f9b\u66f4\u597d\u7684\u652f\u6301\u548c\u4fdd\u969c\uff0c\u78ba\u4fdd\u60a8\u7684\u6578\u64da\u5b89\u5168\u548c\u53ef\u7528\u6027\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5fd8\u8a18 MySQL \u5bc6\u78bc\u600e\u9ebc\u8fa6\uff1f\u672c\u6587\u6559\u4f60\u7c21\u55ae\u67e5\u627e\u65b9\u6cd5\uff0c\u8f15\u9b06\u627e\u56de\u6578\u64da\u5eab\u5bc6\u78bc\uff0c\u4fdd\u969c\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-190204","post","type-post","status-publish","format-standard","hentry","category-database"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/190204","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=190204"}],"version-history":[{"count":1,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/190204\/revisions"}],"predecessor-version":[{"id":190205,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/190204\/revisions\/190205"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=190204"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=190204"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=190204"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}