{"id":1386,"date":"2024-05-08T09:54:56","date_gmt":"2024-05-08T01:54:56","guid":{"rendered":"http:\/\/oneai.eu.org\/?p=1386"},"modified":"2024-05-08T09:54:56","modified_gmt":"2024-05-08T01:54:56","slug":"mysql-%e5%bf%98%e8%ae%b0%e5%8f%a3%e4%bb%a4%e7%9a%84%e8%a7%a3%e5%86%b3%e5%8a%9e%e6%b3%95","status":"publish","type":"post","link":"https:\/\/oneai.eu.org\/?p=1386","title":{"rendered":"MySQL \u5fd8\u8bb0\u53e3\u4ee4\u7684\u89e3\u51b3\u529e\u6cd5"},"content":{"rendered":"<p>MySQL \u5fd8\u8bb0\u53e3\u4ee4\u7684\u89e3\u51b3\u529e\u6cd5<\/p>\n<p>\u5982\u679c MySQL \u6b63\u5728\u8fd0\u884c\uff0c\u9996\u5148\u6740\u4e4b\uff1a killall -TERM mysqld\u3002 <\/p>\n<p>\u542f\u52a8 MySQL \uff1abin\/safe_mysqld --skip-grant-tables &amp; <\/p>\n<p>\u5c31\u53ef\u4ee5\u4e0d\u9700\u8981\u5bc6\u7801\u5c31\u8fdb\u5165 MySQL \u4e86\u3002 <\/p>\n<p>\u7136\u540e\u5c31\u662f <\/p>\n<blockquote>\n<p>use mysql<\/p>\n<p>update user set password=password(&quot;new_pass&quot;) where user=&quot;root&quot;;<\/p>\n<p>flush privileges;<\/p>\n<\/blockquote>\n<p>8.0\u4ee5\u4e0a\u7248\u672c\uff1a<br \/>\nalter user 'root'@'localhost' identified by 'new_passwd';<\/p>\n<h2>\u91cd\u65b0\u6740 MySQL \uff0c\u7528\u6b63\u5e38\u65b9\u6cd5\u542f\u52a8 MySQL \u3002<\/h2>\n<p>\u5982\u679c\u4e0a\u9762\u7684\u65b9\u5f0f\u4e0d\u884c\uff0c\u8bd5\u8bd5\u4e0b\u9762\u7684<br \/>\n\u5982\u679c\u60a8\u4e0d\u5c0f\u5fc3\u5220\u9664\u4e86 MySQL \u6570\u636e\u5e93\u4e2d\u7684 root \u7528\u6237\uff0c\u60a8\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u6b65\u9aa4\u91cd\u65b0\u521b\u5efa\u5e76\u6388\u6743 root \u7528\u6237\uff1a<\/p>\n<p>\u6b65\u9aa4 1\uff1a\u505c\u6b62 MySQL \u670d\u52a1<\/p>\n<p>\u9996\u5148\uff0c\u60a8\u9700\u8981\u505c\u6b62\u6b63\u5728\u8fd0\u884c\u7684 MySQL \u670d\u52a1\u3002\u8fd9\u53d6\u51b3\u4e8e\u60a8\u7684\u64cd\u4f5c\u7cfb\u7edf\u548c\u5b89\u88c5\u65b9\u5f0f\u3002<\/p>\n<p>\u5bf9\u4e8e\u5927\u591a\u6570 Linux \u53d1\u884c\u7248\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<p>sudo service mysql stop<\/p>\n<p>\u6b65\u9aa4 2\uff1a\u4ee5\u4e0d\u68c0\u67e5\u6743\u9650\u7684\u65b9\u5f0f\u542f\u52a8 MySQL\u4e3a\u4e86\u91cd\u65b0\u521b\u5efa root \u7528\u6237\uff0c\u60a8\u9700\u8981\u4ee5\u4e0d\u68c0\u67e5\u6743\u9650\u7684\u65b9\u5f0f\u542f\u52a8 MySQL\u3002\u8fd9\u5c06\u5141\u8bb8\u60a8\u4ee5\u4e0d\u9700\u8981\u5bc6\u7801\u7684\u65b9\u5f0f\u8fde\u63a5\u5230\u670d\u52a1\u5668\u3002<\/p>\n<p>\u5bf9\u4e8e\u5927\u591a\u6570 Linux \u53d1\u884c\u7248\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<p>sudo mysqld_safe --skip-grant-tables --skip-networking &amp;<br \/>\nmysql -u root<\/p>\n<p>\u6b65\u9aa4 4\uff1a\u91cd\u65b0\u521b\u5efa root \u7528\u6237\u5e76\u6388\u6743<\/p>\n<p>\u5728 MySQL \u547d\u4ee4\u63d0\u793a\u7b26\u4e0b\uff0c\u60a8\u53ef\u4ee5\u91cd\u65b0\u521b\u5efa root \u7528\u6237\u5e76\u6388\u6743\uff1a<\/p>\n<p>-- \u521b\u5efa root \u7528\u6237<br \/>\nCREATE USER 'root'@'localhost' IDENTIFIED BY 'your_new_password';   <\/p>\n<p>-- \u7ed9 root \u7528\u6237\u6388\u6743<br \/>\nGRANT ALL PRIVILEGES ON <em>.<\/em> TO 'root'@'localhost' WITH GRANT OPTION;<\/p>\n<p>\u63d0\u793a\u5982\u679c\u4e0a\u9762\u7684sql\u62a5\u9519 \u5219  \u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u8d26\u53f7\u4ee3\u66ff root :grant all privileges on <em>.<\/em> to 'admin'@'localhost'  IDENTIFIED BY 'Familyun@mysql1' with grant option;<br \/>\n-- \u66f4\u65b0\u6743\u9650<br \/>\nFLUSH PRIVILEGES;<\/p>\n<p>EXIT;<\/p>\n<p>\u6b65\u9aa4 5\uff1a\u91cd\u542f MySQL \u670d\u52a1<br \/>\nsudo mysqladmin -u root -p shutdown<br \/>\n\u5982\u679croot\u4e0d\u884c\uff0c\u5219\u7528\u4e0a\u9762\u65b0\u7684admin\u8d26\u53f7<br \/>\nsudo service mysql start<br \/>\nmysql -u root -p<br \/>\n\u8f93\u5165\u60a8\u521a\u521a\u8bbe\u7f6e\u7684\u65b0\u5bc6\u7801\uff0c\u60a8\u5e94\u8be5\u53ef\u4ee5\u6210\u529f\u767b\u5f55\u3002<br \/>\n\u5982\u679c\u4e0d\u884c\uff0c\u7528\u4e0a\u9762\u7684admin\u8d26\u53f7<br \/>\n\u767b\u5f55\u540e\uff0c\u5982\u679c\u8fd8\u60f3\u7528root<br \/>\n\u5219\uff1a<br \/>\nGRANT ALL PRIVILEGES ON <em>.<\/em> TO 'root'@'localhost' IDENTIFIED BY 'Familyun@mysql1' WITH GRANT OPTION;<\/p>\n<p>FLUSH PRIVILEGES;<br \/>\nexit<\/p>\n<p>8.0\u4ee5\u4e0a\u7248\u672c\u8bed\u53e5\u6709\u66f4\u6539\uff1a<br \/>\n\u6539\u5bc6\u7801\uff1aalter user 'usernmae'@'%' identified by 'password';<br \/>\n\u7ed9\u6743\u9650\uff1agrant all privileges on flarum.* to 'username'@'%' with grant option;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>MySQL \u5fd8\u8bb0\u53e3\u4ee4\u7684\u89e3\u51b3\u529e\u6cd5 \u5982\u679c MySQL \u6b63\u5728\u8fd0\u884c\uff0c\u9996\u5148\u6740\u4e4b\uff1a killall -TERM mysqld\u3002 \u542f\u52a8 MySQL \uff1abin\/safe_mysqld &#8211;skip-grant-tables &amp; \u5c31\u53ef\u4ee5\u4e0d\u9700\u8981\u5bc6\u7801\u5c31\u8fdb\u5165 MySQL \u4e86\u3002 \u7136\u540e\u5c31\u662f use mysql update user set password=password(&quot;new_pass&quot;) where user=&quot;root&quot;; flush privileges; 8.0\u4ee5\u4e0a\u7248\u672c\uff1a alter user &#8216;root&#8217;@&#8217;localhost&#8217; identified by &#8216;new_passwd&#8217;; \u91cd\u65b0\u6740 MySQL \uff0c\u7528\u6b63\u5e38\u65b9\u6cd5\u542f\u52a8 MySQL \u3002 \u5982\u679c\u4e0a\u9762\u7684\u65b9\u5f0f\u4e0d\u884c\uff0c\u8bd5\u8bd5\u4e0b\u9762\u7684 \u5982\u679c\u60a8\u4e0d\u5c0f\u5fc3\u5220\u9664\u4e86 MySQL \u6570\u636e\u5e93\u4e2d\u7684 root \u7528\u6237\uff0c\u60a8\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u6b65\u9aa4\u91cd\u65b0\u521b\u5efa\u5e76\u6388\u6743 root \u7528\u6237\uff1a \u6b65\u9aa4 1\uff1a\u505c\u6b62 MySQL \u670d\u52a1 \u9996\u5148\uff0c\u60a8\u9700\u8981\u505c\u6b62\u6b63\u5728\u8fd0\u884c\u7684 MySQL \u670d\u52a1\u3002\u8fd9\u53d6\u51b3\u4e8e\u60a8\u7684\u64cd\u4f5c\u7cfb\u7edf\u548c\u5b89\u88c5\u65b9\u5f0f\u3002 \u5bf9\u4e8e\u5927\u591a\u6570 Linux \u53d1\u884c\u7248\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\uff1a sudo service mysql stop \u6b65\u9aa4 2\uff1a\u4ee5\u4e0d\u68c0\u67e5\u6743\u9650\u7684\u65b9\u5f0f\u542f\u52a8 MySQL\u4e3a\u4e86\u91cd\u65b0\u521b\u5efa root \u7528\u6237\uff0c\u60a8\u9700\u8981\u4ee5\u4e0d\u68c0\u67e5\u6743\u9650\u7684\u65b9\u5f0f\u542f\u52a8 MySQL\u3002\u8fd9\u5c06\u5141\u8bb8\u60a8\u4ee5\u4e0d\u9700\u8981\u5bc6\u7801\u7684\u65b9\u5f0f\u8fde\u63a5\u5230\u670d\u52a1\u5668\u3002 \u5bf9\u4e8e\u5927\u591a\u6570 Linux \u53d1\u884c\u7248\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\uff1a sudo mysqld_safe &#8211;skip-grant-tables &#8211;skip-networking &amp; mysql -u root \u6b65\u9aa4 4\uff1a\u91cd\u65b0\u521b\u5efa root \u7528\u6237\u5e76\u6388\u6743 \u5728 MySQL \u547d\u4ee4\u63d0\u793a\u7b26\u4e0b\uff0c\u60a8\u53ef\u4ee5\u91cd\u65b0\u521b\u5efa root \u7528\u6237\u5e76\u6388\u6743\uff1a &#8212; \u521b\u5efa root \u7528\u6237 CREATE USER &#8216;root&#8217;@&#8217;localhost&#8217; IDENTIFIED BY &#8216;your_new_password&#8217;; &#8212; \u7ed9 root \u7528\u6237\u6388\u6743 GRANT ALL PRIVILEGES ON . TO &#8216;root&#8217;@&#8217;localhost&#8217; WITH GRANT OPTION; \u63d0\u793a\u5982\u679c\u4e0a\u9762\u7684sql\u62a5\u9519 \u5219 \u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u8d26\u53f7\u4ee3\u66ff root :grant all privileges on . to &#8216;admin&#8217;@&#8217;localhost&#8217; IDENTIFIED BY &#8216;Familyun@mysql1&#8217; with grant option; &#8212; \u66f4\u65b0\u6743\u9650 FLUSH PRIVILEGES; EXIT; \u6b65\u9aa4 5\uff1a\u91cd\u542f MySQL \u670d\u52a1 sudo mysqladmin -u root -p shutdown \u5982\u679croot\u4e0d\u884c\uff0c\u5219\u7528\u4e0a\u9762\u65b0\u7684admin\u8d26\u53f7 sudo service mysql start mysql -u root -p \u8f93\u5165\u60a8\u521a\u521a\u8bbe\u7f6e\u7684\u65b0\u5bc6\u7801\uff0c\u60a8\u5e94\u8be5\u53ef\u4ee5\u6210\u529f\u767b\u5f55\u3002 \u5982\u679c\u4e0d\u884c\uff0c\u7528\u4e0a\u9762\u7684admin\u8d26\u53f7 \u767b\u5f55\u540e\uff0c\u5982\u679c\u8fd8\u60f3\u7528root \u5219\uff1a GRANT ALL PRIVILEGES ON . TO &#8216;root&#8217;@&#8217;localhost&#8217; IDENTIFIED BY &#8216;Familyun@mysql1&#8217; WITH GRANT OPTION; FLUSH PRIVILEGES; exit 8.0\u4ee5\u4e0a\u7248\u672c\u8bed\u53e5\u6709\u66f4\u6539\uff1a \u6539\u5bc6\u7801\uff1aalter user &#8216;usernmae&#8217;@&#8217;%&#8217; identified by &#8216;password&#8217;; \u7ed9\u6743\u9650\uff1agrant all privileges on flarum.* to &#8216;username&#8217;@&#8217;%&#8217; with grant option;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_eb_attr":"","footnotes":""},"categories":[83],"tags":[],"class_list":["post-1386","post","type-post","status-publish","format-standard","hentry","category-mysql"],"_links":{"self":[{"href":"https:\/\/oneai.eu.org\/index.php?rest_route=\/wp\/v2\/posts\/1386","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/oneai.eu.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/oneai.eu.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/oneai.eu.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/oneai.eu.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1386"}],"version-history":[{"count":1,"href":"https:\/\/oneai.eu.org\/index.php?rest_route=\/wp\/v2\/posts\/1386\/revisions"}],"predecessor-version":[{"id":1387,"href":"https:\/\/oneai.eu.org\/index.php?rest_route=\/wp\/v2\/posts\/1386\/revisions\/1387"}],"wp:attachment":[{"href":"https:\/\/oneai.eu.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1386"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/oneai.eu.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1386"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/oneai.eu.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1386"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}