{"id":384,"date":"2016-01-25T17:13:38","date_gmt":"2016-01-25T09:13:38","guid":{"rendered":"http:\/\/owemeawe.com\/?p=384"},"modified":"2017-04-28T08:43:16","modified_gmt":"2017-04-28T08:43:16","slug":"mysql%e7%99%bb%e5%bd%95%e9%94%99%e8%af%af%e7%9a%84%e8%a7%a3%e5%86%b3%e6%96%b9%e6%b3%95","status":"publish","type":"post","link":"https:\/\/peloo.net\/?p=384","title":{"rendered":"mysql\u767b\u5f55\u9519\u8bef\u7684\u89e3\u51b3\u65b9\u6cd5"},"content":{"rendered":"<p>\n\t<span style=\"color: #ff0000\"><strong>\u4e00\u3001mysql\u767b\u5f55\u9519\u8bef<\/strong><\/span>\n<\/p>\n<p>\n\tmysqladmin: connect to server at &#039;localhost&#039; failed\n<\/p>\n<p>\n\terror: &#039;Access denied for user &#039;root&#039;@&#039;localhost&#039; (using password: NO)&#039;\n<\/p>\n<p>\n\t\u89e3\u51b3\u529e\u6cd5\uff1a\u7834\u89e3mysql\u5bc6\u7801\n<\/p>\n<p>\n\t1&gt;\u505c\u6b62mysql\u670d\u52a1\uff1aservice mysqld stop\n<\/p>\n<p>\n\t2&gt;\u6740\u6b7b\u6240\u6709mysqld\u76f8\u5173\u7684\u8fdb\u7a0b\uff0c\u5efa\u8bae\u4f7f\u7528kill -9 \uff0c\u4e00\u6b65\u5230\u4f4d\n<\/p>\n<p>\n\t3&gt;\u6267\u884c\u547d\u4ee4\uff1a&gt; mysqld_safe --skip-grant-tables &amp; mysql -uroot -p \u56de\u8f66\u8fdb\u5165\n<\/p>\n<p>\n\t&gt; use mysql;\n<\/p>\n<p>\n\t&gt; update user set password=PASSWORD(&quot;newpass&quot;)where user=&quot;root&quot;;\n<\/p>\n<p>\n\t\u66f4\u6539\u5bc6\u7801\u4e3a newpass\n<\/p>\n<p>\n\t&gt; flush privileges; \u66f4\u65b0\u6743\u9650\n<\/p>\n<p>\n\t&gt; quit \u9000\u51fa\n<\/p>\n<p>\n\t4&gt;\u91cd\u542fmysql\u670d\u52a1\uff1aservice mysqld restart\n<\/p>\n<p>\n\t5&gt;\u8fde\u63a5\u6570\u636e\u5e93\uff1amysql -uroot -p new-passwd\n<\/p>\n<p>\n\t<strong><span style=\"color: #ff0000\">\u4e8c\u3001\u5fd8\u8bb0\u672c\u5730root\u7684\u767b\u5f55\u5bc6\u7801<\/span><\/strong>\n<\/p>\n<p>\n\t\u89e3\u51b3\u8fc7\u7a0b\uff1a\n<\/p>\n<p>\n\t1\u3001\u7f16\u8f91\/etc\/my.cnf\n<\/p>\n<p>\n\t\u5728[mysqld] \u914d\u7f6e\u90e8\u5206\u6dfb\u52a0\u4e00\u884c\n<\/p>\n<p>\n\tskip-grant-tables\n<\/p>\n<p>\n\t2\u3001\u4fdd\u5b58\u540e\u91cd\u542fmysql\n<\/p>\n<p>\n\t[root@localhost etc]# service mysqld restart<br \/>\n\t3\u3001\u767b\u5f55\u6570\u636e\u5e93\u91cd\u65b0\u8bbe\u7f6eroot\u5bc6\u7801\n<\/p>\n<p>\n\t[root@localhost ~]# mysql -uroot -p mysql<br \/>\n\tEnter password:\n<\/p>\n<p>\n\t\u76f4\u63a5\u56de\u8f66\u8fdb\u5165\n<\/p>\n<p>\n\tmysql&gt; show databases;<br \/>\n\t\u6267\u884c\u4e0b\u5217\u8bed\u53e5<br \/>\n\tmysql&gt; update user set password=password(&quot;mysql&quot;) where user=&#039;root&#039;;<br \/>\n\tmysql&gt; flush privileges;\n<\/p>\n<p>\n\t4\u3001\u5220\u9664\/etc\/my.cnf\u6587\u4ef6\u4e2d\u6dfb\u52a0\u7684&ldquo;skip-grant-tables&rdquo;\u884c\uff0c\u91cd\u542fmysql\uff1b\n<\/p>\n<p>\n\t\u7528\u65b0\u8bbe\u7684\u5bc6\u7801\u5c31\u80fd\u6b63\u5e38\u767b\u5f55\u4e86\uff1b<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4e00\u3001mysql\u767b\u5f55\u9519\u8bef mysqladmin: connect to server at &#039;localhost&#039; failed error: &#039;Access denied for user &#039;root&#039;@&#039;localhost&#039; (using password: NO)&#039; \u89e3\u51b3\u529e\u6cd5\uff1a\u7834\u89e3mysql\u5bc6\u7801 1&gt;\u505c\u6b62mysql\u670d\u52a1\uff1aservice mysqld stop 2&gt;\u6740\u6b7b\u6240\u6709mysqld\u76f8\u5173\u7684\u8fdb\u7a0b\uff0c\u5efa\u8bae\u4f7f\u7528kill -9 \uff0c\u4e00\u6b65\u5230\u4f4d 3&gt;\u6267\u884c\u547d\u4ee4\uff1a&gt; mysqld_safe &#8211;skip-grant-tables &amp; mysql -uroot -p \u56de\u8f66\u8fdb\u5165 &gt; use mysql; &gt; update user set password=PASSWORD(&quot;newpass&quot;)where user=&quot;root&quot;; \u66f4\u6539\u5bc6\u7801\u4e3a newpass &gt; flush privileges; \u66f4\u65b0\u6743\u9650 &gt; quit \u9000\u51fa 4&gt;\u91cd\u542fmysql\u670d\u52a1\uff1aservice mysqld restart 5&gt;\u8fde\u63a5\u6570\u636e\u5e93\uff1amysql -uroot&#8230;<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[],"class_list":["post-384","post","type-post","status-publish","format-standard","hentry","category-linux"],"aioseo_notices":[],"brizy_media":[],"_links":{"self":[{"href":"https:\/\/peloo.net\/index.php?rest_route=\/wp\/v2\/posts\/384","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/peloo.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/peloo.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/peloo.net\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/peloo.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=384"}],"version-history":[{"count":3,"href":"https:\/\/peloo.net\/index.php?rest_route=\/wp\/v2\/posts\/384\/revisions"}],"predecessor-version":[{"id":873,"href":"https:\/\/peloo.net\/index.php?rest_route=\/wp\/v2\/posts\/384\/revisions\/873"}],"wp:attachment":[{"href":"https:\/\/peloo.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=384"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/peloo.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=384"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/peloo.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=384"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}