{"id":914,"date":"2018-07-08T15:39:19","date_gmt":"2018-07-08T07:39:19","guid":{"rendered":"https:\/\/blog.freesilo.com\/?p=914"},"modified":"2018-07-08T15:39:19","modified_gmt":"2018-07-08T07:39:19","slug":"%e5%88%9d%e6%ac%a1%e5%ae%89%e8%a3%85mysql5-7%e4%bb%a5%e4%b8%8a%e7%89%88%e6%9c%ac%e5%90%8e%e5%88%9d%e5%a7%8broot%e5%af%86%e7%a0%81%e6%89%be%e4%b8%8d%e5%88%b0%e7%9a%84%e9%97%ae%e9%a2%98","status":"publish","type":"post","link":"https:\/\/freesilo.com\/?p=914","title":{"rendered":"\u521d\u6b21\u5b89\u88c5Mysql5.7\u4ee5\u4e0a\u7248\u672c\u540e\u521d\u59cbroot\u5bc6\u7801\u627e\u4e0d\u5230\u7684\u95ee\u9898"},"content":{"rendered":"<p>mysql5.7\u65b0\u589e\u7684\u7279\u6027\u4e2d\u4e3b\u8981\u7684\u4e00\u65b9\u9762\u5c31\u662f\u6781\u5927\u589e\u5f3a\u4e86\u5b89\u5168\u6027\uff0c\u5b89\u88c5Mysql\u540e\u9ed8\u8ba4\u4f1a\u4e3aroot@localhost\u7528\u6237\u521b\u5efa\u4e00\u4e2a\u968f\u673a\u5bc6\u7801\uff0c\u8fd9\u4e2a\u968f\u673a\u5bc6\u7801\u5728\u4e0d\u540c\u7cfb\u7edf\u4e0a\u9700\u8981\u4f7f\u7528\u4e0d\u540c\u65b9\u5f0f\u67e5\u627e\uff0c\u5426\u5219\u65e0\u6cd5\u767b\u5f55mysql\u5e76\u4fee\u6539\u521d\u59cb\u5bc6\u7801\u3002<\/p>\n<p>\u4ee5\u4e0b\u4ee5Centos 7\u4e3a\u4f8b\u4ecb\u7ecd\u5982\u4f55\u627e\u5230\u521d\u59cb\u7684\u968f\u673a\u5bc6\u7801\u3002<\/p>\n<p>\u5728\u4f4e\u4e8eMysql 5.7.6\u7684\u7248\u672c\u4e0a\uff0cMysql\u662f\u4f7f\u7528mysql_install_db\u547d\u4ee4\u521d\u59cb\u5316\u6570\u636e\u5e93\u7684\uff0c\u8be5\u547d\u4ee4\u4f1a\u5728\u5b89\u88c5Mysql\u7684\u7528\u6237\u6839\u76ee\u5f55\u4e0b\u521b\u5efa\u4e00\u4e2a.mysql_secret\u6587\u4ef6\uff0c\u8be5\u6587\u4ef6\u8bb0\u5f55\u4e86\u521d\u59cb\u5316\u751f\u6210\u7684\u968f\u673a\u5bc6\u7801\uff0c\u7528\u6237\u53ef\u4f7f\u7528\u6539\u5bc6\u7801\u767b\u5f55Mysql\u5e76\u91cd\u65b0\u4fee\u6539\u5bc6\u7801\u3002<\/p>\n<p>\u5bf9\u4e8eMysql 5.7.6\u4ee5\u540e\u76845.7\u7cfb\u5217\u7248\u672c\uff0cMysql\u4f7f\u7528mysqld &#8211;initialize\u6216mysqld &#8211;initialize-insecure\u547d\u4ee4\u6765\u521d\u59cb\u5316\u6570\u636e\u5e93\uff0c\u540e\u8005\u53ef\u4ee5\u4e0d\u751f\u6210\u968f\u673a\u5bc6\u7801\u3002\u4f46\u662f\u5b89\u88c5Mysql\u65f6\u9ed8\u8ba4\u4f7f\u7528\u7684\u662f\u524d\u4e00\u4e2a\u547d\u4ee4\uff0c\u8fd9\u4e2a\u547d\u4ee4\u4e5f\u4f1a\u751f\u6210\u4e00\u4e2a\u968f\u673a\u5bc6\u7801\u3002\u6539\u5bc6\u7801\u4fdd\u5b58\u5728\u4e86Mysql\u7684\u65e5\u5fd7\u6587\u4ef6\u4e2d\u3002<\/p>\n<p>\u5728Centos 7\u7cfb\u7edf\u4e0a\u4f7f\u7528rpm\u547d\u4ee4\u5b89\u88c5Mysql\u540e\uff0cmysql\u7684\u914d\u7f6e\u6587\u4ef6\u662f\/etc\/my.cnf\uff0c\u6253\u5f00\u8be5\u6587\u4ef6\uff0c\u53ef\u4ee5\u770b\u5230mysql\u7684datadir\u548clog\u6587\u4ef6\u7b49\u7684\u914d\u7f6e\u4fe1\u606f\uff0c\u5982\u4e0b\uff1a<\/p>\n<p>datadir=\/var\/lib\/mysql<\/p>\n<p>log-error=\/var\/log\/mysqld.log<\/p>\n<p>\u6253\u5f00\/var\/log\/mysqld.log\u6587\u4ef6\uff0c\u641c\u7d22\u5b57\u7b26\u4e32A temporary password is generated for root@localhost:\uff0c\u53ef\u4ee5\u627e\u5230\u8fd9\u4e2a\u968f\u673a\u5bc6\u7801\uff0c\u901a\u5e38\u8fd9\u4e00\u884c\u65e5\u5fd7\u5728log\u6587\u4ef6\u7684\u6700\u521d\u51e0\u884c\uff0c\u6bd4\u8f83\u5bb9\u6613\u770b\u5230\u3002<\/p>\n<p>\u4f7f\u7528\u627e\u5230\u7684\u968f\u673a\u5bc6\u7801\u767b\u5f55mysql\uff0c\u9996\u6b21\u767b\u5f55\u540e\uff0cmysql\u8981\u6bd4\u5fc5\u987b\u4fee\u6539\u9ed8\u8ba4\u5bc6\u7801\uff0c\u5426\u5219\u4e0d\u80fd\u6267\u884c\u4efb\u4f55\u5176\u4ed6\u6570\u636e\u5e93\u64cd\u4f5c\uff0c\u8fd9\u6837\u4f53\u73b0\u4e86\u4e0d\u65ad\u589e\u5f3a\u7684Mysql\u5b89\u5168\u6027\u3002<\/p>\n<hr \/>\n<p>\u4e0d\u517c\u5bb9\u7684\u66f4\u6539\uff1aMySQL\u7684\u90e8\u7f72\u5b89\u88c5\u4f7f\u7528mysql_install_db\uff0c\u73b0\u5728\u9ed8\u8ba4\u662f\u5b89\u5168\u7684\u3002\u4e0b\u9762\u7684\u66f4\u6539\u5df2\u88ab\u5b9e\u73b0\u5e76\u6210\u4e3a\u9ed8\u8ba4\u90e8\u7f72\u7279\u6027\uff1a<\/p>\n<p>\u5728\u5b89\u88c5\u7684\u8fc7\u7a0b\u91cc\uff0c\u5c06\u4ec5\u521b\u5efa\u4e00\u4e2aroot\u8d26\u6237\u2014\u2014&#8217;root&#8217;@&#8217;localhost&#8217;\uff0c<strong>\u540c\u65f6\u5c06\u81ea\u52a8\u751f\u6210\u4e00\u4e2a\u968f\u673a\u5bc6\u7801\u7ed9\u5b83<\/strong>\uff0c\u5e76\u6807\u8bb0\u6b64\u5bc6\u7801\u5df2\u8fc7\u671f\u3002<strong>MySQL<\/strong><strong>\u7ba1\u7406\u5458\u5fc5\u987b\u4f7f\u7528\u968f\u673a\u5bc6\u7801\u767b\u9646root<\/strong><strong>\u8d26\u6237\uff0c\u5e76\u4f7f\u7528SET PASSWORD<\/strong><strong>\u53bb\u8bbe\u7f6e\u4e00\u4e2a\u65b0\u7684\u5bc6\u7801<\/strong>\u3002\uff08<strong>\u968f\u673a\u5bc6\u7801\u53ef\u4ee5\u5728\u8fd0\u884c\u5b89\u88c5\u811a\u672c\u7684\u6709\u6548\u7528\u6237\u5176\u4e3b\u76ee\u5f55\u4e2d\u7684<\/strong><strong>.mysql_secret<\/strong><strong>\u6587\u4ef6\u4e2d\u627e\u5230\u3002<\/strong>\uff09<\/p>\n<hr \/>\n<p>&nbsp;<\/p>\n<p>CentOS\u7cfb\u7edf\u7528yum\u5b89\u88c5MySQL\u7684\u670b\u53cb\uff0c\u8bf7\u4f7f\u7528\u00a0<span style=\"color: #ff0000;\"><em><strong>grep &#8220;temporary\u00a0password&#8221; \/var\/log\/mysqld.log<\/strong><\/em>\u00a0<\/span>\u547d\u4ee4\uff0c\u8fd4\u56de\u7ed3\u679c\u6700\u540e\u5f15\u53f7\u540e\u9762\u7684\u5b57\u7b26\u4e32\u5c31\u662froot\u7684\u9ed8\u8ba4\u5bc6\u7801\u3002<\/p>\n<p>\uff08\u5982\u679c\u4e0d\u5b58\u5728\/var\/log\/mysqld.log\u6587\u4ef6\uff0c\u8bf7\u786e\u4fdd\u60a8\u5df2\u7ecf\u542f\u52a8\u8fc7\u4e00\u6b21MySQL\u670d\u52a1\u3002CentOS 7\u542f\u52a8MySQL\u670d\u52a1\u7684\u547d\u4ee4\u662f\uff1a<em><strong>systemctl start mysqld.service<\/strong><\/em>\uff09<\/p>\n<p><em><strong>sudo mysql_install_db <\/strong><\/em><\/p>\n<p><em><strong>grep &#8220;temporary\u00a0password&#8221; \/var\/log\/mysqld.log<\/strong><\/em><\/p>\n<p><em><strong>sudo find \/ -name .mysql_secret<\/strong><\/em><\/p>\n<p><em><strong>mysql -uroot -p<\/strong><\/em><\/p>\n<p><em><strong>SET PASSWORD = PASSWORD(&#8216;\u4f60\u7684\u65b0\u5bc6\u7801&#8217;);<\/strong><\/em><\/p>\n","protected":false},"excerpt":{"rendered":"<p>mysql5.7\u65b0\u589e\u7684\u7279\u6027\u4e2d\u4e3b\u8981\u7684\u4e00\u65b9\u9762\u5c31\u662f\u6781\u5927\u589e\u5f3a\u4e86\u5b89\u5168\u6027\uff0c\u5b89\u88c5Mysql\u540e\u9ed8&#8230;<br \/><a class=\"read-more-button\" href=\"https:\/\/freesilo.com\/?p=914\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[18],"tags":[],"class_list":["post-914","post","type-post","status-publish","format-standard","hentry","category-mysql"],"_links":{"self":[{"href":"https:\/\/freesilo.com\/index.php?rest_route=\/wp\/v2\/posts\/914","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/freesilo.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/freesilo.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/freesilo.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/freesilo.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=914"}],"version-history":[{"count":1,"href":"https:\/\/freesilo.com\/index.php?rest_route=\/wp\/v2\/posts\/914\/revisions"}],"predecessor-version":[{"id":918,"href":"https:\/\/freesilo.com\/index.php?rest_route=\/wp\/v2\/posts\/914\/revisions\/918"}],"wp:attachment":[{"href":"https:\/\/freesilo.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=914"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/freesilo.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=914"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/freesilo.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=914"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}