{"id":54,"date":"2017-09-05T10:19:39","date_gmt":"2017-09-05T02:19:39","guid":{"rendered":"http:\/\/lst.wting.me\/?p=54"},"modified":"2017-09-05T10:20:17","modified_gmt":"2017-09-05T02:20:17","slug":"mysql%e4%bf%ae%e6%94%b9root%e5%af%86%e7%a0%81%e5%90%8e%e4%be%9d%e7%84%b6%e6%97%a0%e6%b3%95%e7%99%bb%e9%99%86%e7%9a%84%e5%8e%9f%e5%9b%a0%e5%88%86%e6%9e%90","status":"publish","type":"post","link":"https:\/\/lst.wting.top\/?p=54","title":{"rendered":"MySQL\u4fee\u6539root\u5bc6\u7801\u540e\u4f9d\u7136\u65e0\u6cd5\u767b\u9646\u7684\u539f\u56e0\u5206\u6790"},"content":{"rendered":"<p>\u6253\u5f00\u535a\u5ba2\uff0c\u7a81\u7136\u53d1\u73b0\u535a\u5ba2\u6253\u4e0d\u5f00\u4e86\uff0c\u62a5\u9519\uff0c\u6570\u636e\u5e93\u8fde\u63a5\u9519\u8bef\u3002<\/p>\n<p>\u6069\uff0c\u4e00\u5b9a\u662f\u5bc6\u7801\u9519\u8bef\uff0c\u767b\u9646ssh\uff0c\u6572\u547d\u4ee4\uff1amysql -u root -p<\/p>\n<p>\u7136\u540e\u8f93\u5165\u5bc6\u7801\uff0c\u54a6\uff0c1045\u7981\u6b62\u767b\u9646\uff0c\u518d\u6b21\u8f93\u5165\uff0c\u8fd8\u662f1045\u9519\u8bef\u3002<\/p>\n<p>\u597d\u5427\uff0c\u4e5f\u8bb8\u662froot\u5bc6\u7801\u5fd8\u4e86\u3002<\/p>\n<p>\u4fee\u6539\u5bc6\u7801\u3002<\/p>\n<p>&nbsp;<\/p>\n<p># vi \/etc\/my.cnf<br \/>\n\u5728[mysqld]\u7684\u6bb5\u4e2d\u52a0\u4e0a\u4e00\u53e5\uff1askip-grant-tables<br \/>\n\u4f8b\u5982\uff1a<br \/>\n[mysqld]<br \/>\ndatadir=\/var\/lib\/mysql<br \/>\nsocket=\/var\/lib\/mysql\/mysql.sock<br \/>\nskip-grant-tables<br \/>\n\u4fdd\u5b58\u5e76\u4e14\u9000\u51favi\u3002<br \/>\n3\uff0e\u91cd\u65b0\u542f\u52a8mysqld<br \/>\n# \/etc\/init.d\/mysqld restart<br \/>\nStopping MySQL: [ OK ]<br \/>\nStarting MySQL: [ OK ]<br \/>\n4\uff0e\u767b\u5f55\u5e76\u4fee\u6539MySQL\u7684root\u5bc6\u7801<br \/>\n# \/usr\/bin\/mysql<br \/>\nWelcome to the MySQL monitor. Commands end with ; or \\g.<br \/>\nYour MySQL connection id is 3 to server version: 3.23.56<br \/>\nType &#8216;help;&#8217; or &#8216;\\h&#8217; for help. Type &#8216;\\c&#8217; to clear the buffer.<br \/>\nmysql&gt; USE mysql ;<br \/>\nReading table information for completion of table and column names<br \/>\nYou can turn off this feature to get a quicker startup with -A<br \/>\nDatabase changed<br \/>\nmysql&gt; UPDATE user SET Password = password ( &#8216;new-password&#8217; ) WHERE User = &#8216;root&#8217; ;<br \/>\nQuery OK, 0 rows affected (0.00 sec)<br \/>\nRows matched: 2 Changed: 0 Warnings: 0<br \/>\nmysql&gt; flush privileges ;<br \/>\nQuery OK, 0 rows affected (0.01 sec)<br \/>\nmysql&gt; quit<br \/>\nBye<br \/>\n5\uff0e\u5c06MySQL\u7684\u767b\u5f55\u8bbe\u7f6e\u4fee\u6539\u56de\u6765<br \/>\n# vi \/etc\/my.cnf<br \/>\n\u5c06\u521a\u624d\u5728[mysqld]\u7684\u6bb5\u4e2d\u52a0\u4e0a\u7684skip-grant-tables\u5220\u9664<br \/>\n\u4fdd\u5b58\u5e76\u4e14\u9000\u51favi\u3002<br \/>\n6\uff0e\u91cd\u65b0\u542f\u52a8mysqld<br \/>\n# \/etc\/init.d\/mysqld restart<br \/>\nStopping MySQL: [ OK ]<br \/>\nStarting MySQL: [ OK ]<\/p>\n<p>&nbsp;<\/p>\n<p>\u4fee\u6539\u5b8c\u4e86\uff0c\u518d\u6b21\u4f7f\u7528mysql -u root -p\uff0c\u54a6\uff0c\u4f9d\u7136\u4e0d\u5bf9\u3002\u6211\u660e\u660e\u5df2\u7ecf\u6539\u8fc7\u4e86\u3002<\/p>\n<p>\u518d\u6539\uff0c\u8fd8\u662f\u4e0d\u5bf9\u3002<\/p>\n<p>\u7a81\u7136\uff0c\u6211\u53d1\u73b0\uff0c1045\u62a5\u9519\u53e5\u5b50\u4e2d\uff1a<\/p>\n<p>ERROR 1045 (28000): Access denied for user &#8216;mysql&#8217;@&#8217;localhost&#8217; (using password: YES)<\/p>\n<p>\u6709\u4e00\u4e2alocalhost\uff0c\u83ab\u975e\u662f\u8fd9\u4e2a\u95ee\u9898\uff1f<\/p>\n<p>\u518d\u6b21\u8df3\u8fc7MySQL\u5bc6\u7801\u68c0\u67e5\uff0c\u91cd\u542f\uff0c\u4e0d\u7528\u5bc6\u7801\u767b\u5f55\u540e\uff0c\u9009\u62e9\u6570\u636e\u5e93\uff0c\u7136\u540e\u6267\u884c\uff1a<\/p>\n<p>select * from user;<\/p>\n<p>\u545c\u547c\uff01\u539f\u6765root\u7684Host\u662f127.0.0.1\uff01\u6211\u731c\u4e00\u5b9a\u662f\u8fd9\u4e2a\u95ee\u9898\u3002\u7136\u540e\u4f7f\u7528\u66f4\u65b0\u8bed\u53e5\u628aHost\u6539\u4e3a\u4e86locahost\uff0c\u679c\u7136\u597d\u4e86\uff01<\/p>\n<p>\u4f46\u662f\uff0c\u4e3a\u4ec0\u4e48\u4e24\u4e2a\u4e0d\u4e00\u6837\u5462\uff1f\u641c\u7d22\u4e86\u4e00\u4e0b\uff0c\u6709\u7684\u8bf4\u4e24\u4e2a\u5730\u5740\u8fd8\u662f\u4e0d\u80fd\u901a\u7528\u7684\u3002\u6700\u76f4\u63a5\u7684\u529e\u6cd5\u662f\uff1a<\/p>\n<p>update user set Host=&#8217;%&#8217; where user=&#8217;root&#8217;;<\/p>\n<p>\u8fd9\u6837\uff0c%\u8868\u793a\u6240\u6709\u5305\u62eclocalhost\u548c127.0.0.1\u6216\u8005\u5176\u4ed6\uff0c\u5c31\u80fd\u4fdd\u8bc1\u4e0d\u8bba\u7a0b\u5e8f\u4e2d\u914d\u7f6e\u7684\u662f127.0.0.1\u8fd8\u662flocalhost\u90fd\u80fd\u987a\u5229\u8fde\u63a5\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6253\u5f00\u535a\u5ba2\uff0c\u7a81\u7136\u53d1\u73b0\u535a\u5ba2\u6253\u4e0d\u5f00\u4e86\uff0c\u62a5\u9519\uff0c\u6570\u636e\u5e93\u8fde\u63a5\u9519\u8bef\u3002 \u6069\uff0c\u4e00\u5b9a\u662f\u5bc6\u7801\u9519\u8bef\uff0c\u767b\u9646ssh\uff0c\u6572\u547d\u4ee4\uff1amysql &#8211; [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[4,8],"tags":[],"_links":{"self":[{"href":"https:\/\/lst.wting.top\/index.php?rest_route=\/wp\/v2\/posts\/54"}],"collection":[{"href":"https:\/\/lst.wting.top\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lst.wting.top\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lst.wting.top\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/lst.wting.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=54"}],"version-history":[{"count":1,"href":"https:\/\/lst.wting.top\/index.php?rest_route=\/wp\/v2\/posts\/54\/revisions"}],"predecessor-version":[{"id":55,"href":"https:\/\/lst.wting.top\/index.php?rest_route=\/wp\/v2\/posts\/54\/revisions\/55"}],"wp:attachment":[{"href":"https:\/\/lst.wting.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=54"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lst.wting.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=54"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lst.wting.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=54"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}