{"id":1144,"date":"2019-06-08T08:28:32","date_gmt":"2019-06-08T00:28:32","guid":{"rendered":"https:\/\/freesilo.com\/?p=1144"},"modified":"2019-12-29T15:50:02","modified_gmt":"2019-12-29T07:50:02","slug":"centos7%e4%bd%bf%e7%94%a8yum%e5%ae%89%e8%a3%85mysql","status":"publish","type":"post","link":"https:\/\/freesilo.com\/?p=1144","title":{"rendered":"CentOS7\u4f7f\u7528yum\u5b89\u88c5MySQL"},"content":{"rendered":"<p>1\u3001CentOS7\u7684yum\u6e90\u4e2d\u9ed8\u8ba4\u662f\u6ca1\u6709mysql\u7684\uff0c\u6211\u4eec\u5148\u4e0b\u8f7dmysql\u7684repo\u6e90<\/p>\n<pre class=\"brush:bash;toolbar:false\">wget\u00a0http:\/\/repo.mysql.com\/mysql-community-release-el7-5.noarch.rpm<\/pre>\n<p><img decoding=\"async\" title=\"1543909018804045612.png\" draggable=\"false\" src=\"https:\/\/freesilo.com\/wp-content\/uploads\/2019\/04\/dc754a3d59e31c82b47b8ecddce511dc.png\" alt=\"image.png\" \/><\/p>\n<p>2\u3001\u5b89\u88c5mysql-community-release-el7-5.noarch.rpm\u5305<\/p>\n<pre class=\"brush:bash;toolbar:false\">sudo\u00a0rpm\u00a0-ivh\u00a0mysql-community-release-el7-5.noarch.rpm<\/pre>\n<p><img decoding=\"async\" title=\"1543909214953046942.png\" draggable=\"false\" src=\"https:\/\/freesilo.com\/wp-content\/uploads\/2019\/04\/6c0dece3006938fb4bf6c66169ded387.png\" alt=\"image.png\" \/><\/p>\n<p>3\u3001\u5b89\u88c5mysql\uff0c\u6839\u636e\u63d0\u793a\u5b89\u88c5\u5373\u53ef<\/p>\n<pre class=\"brush:bash;toolbar:false\">sudo\u00a0yum\u00a0install\u00a0mysql-server<\/pre>\n<p><img decoding=\"async\" title=\"1543909419826016345.png\" draggable=\"false\" src=\"https:\/\/freesilo.com\/wp-content\/uploads\/2019\/04\/e837aeca4a7bdda1c337b4f4c17ace0a.png\" alt=\"image.png\" \/><\/p>\n<p><img decoding=\"async\" title=\"1543909464112024245.png\" draggable=\"false\" src=\"https:\/\/freesilo.com\/wp-content\/uploads\/2019\/04\/11f1cc0b60b52f9878dff1e736760f20.png\" alt=\"image.png\" \/><\/p>\n<p>4\u3001\u5b89\u88c5\u5b8c\u6210\u540e\u6ca1\u6709\u5bc6\u7801\uff0c\u9700\u8981\u91cd\u7f6e\u5bc6\u7801<\/p>\n<pre class=\"brush:bash;toolbar:false\">mysql\u00a0-u\u00a0root<\/pre>\n<p>\u767b\u5f55\u65f6\u6709\u53ef\u80fd\u62a5\u8fd9\u6837\u7684\u9519\uff1aERROR 2002 (HY000): Can\u2018t connect to local MySQL server through socket \u2018\/var\/lib\/mysql\/mysql.sock\u2018 (2)\uff0c\u539f\u56e0\u662f\/var\/lib\/mysql\u7684\u8bbf\u95ee\u6743\u9650\u95ee\u9898\u3002\u4e0b\u9762\u7684\u547d\u4ee4\u628a\/var\/lib\/mysql\u7684\u62e5\u6709\u8005\u6539\u4e3a\u5f53\u524d\u7528\u6237<\/p>\n<pre class=\"brush:bash;toolbar:false\">sudo\u00a0chown\u00a0-R\u00a0root:root\u00a0\/var\/lib\/mysql<\/pre>\n<p>\u91cd\u542fmysql\u670d\u52a1<\/p>\n<pre class=\"brush:bash;toolbar:false\">service\u00a0mysqld\u00a0restart<\/pre>\n<p>\u63a5\u4e0b\u6765\u91cd\u7f6eroot\u7528\u6237\u5bc6\u7801\uff1a<\/p>\n<pre class=\"brush:bash;toolbar:false\">mysql\u00a0-u\u00a0root\u00a0\u00a0\/\/\u76f4\u63a5\u56de\u8f66\u8fdb\u5165mysql\u63a7\u5236\u53f0<\/pre>\n<pre class=\"brush:bash;toolbar:false\">use\u00a0mysql;<\/pre>\n<pre class=\"brush:bash;toolbar:false\">update\u00a0user\u00a0set\u00a0password=password('111111')\u00a0where\u00a0user='root';<\/pre>\n<p><img decoding=\"async\" title=\"1543910031204086742.png\" draggable=\"false\" src=\"https:\/\/freesilo.com\/wp-content\/uploads\/2019\/04\/e2a26414ead93104b833f9f17d30c795.png\" alt=\"image.png\" \/><\/p>\n<p>\u6574\u4e2a\u5b89\u88c5\u5b8c\u6210\uff01<\/p>\n<p>PS:<\/p>\n<p>\u5141\u8bb8\u4f7f\u7528\u7528\u6237\u540droot\u5bc6\u7801123456\u4ece\u4efb\u4f55\u4e3b\u673a\u8fde\u63a5\u5230mysql\u670d\u52a1\u5668<\/p>\n<p>mysql&gt;GRANT ALL PRIVILEGES ON *.* TO &#8216;root&#8217;@&#8217;%&#8217; IDENTIFIED BY &#8216;111111&#8217; WITH GRANT OPTION;<\/p>\n<p>\u5237\u65b0\u6743\u9650<\/p>\n<p>mysql&gt;FLUSH PRIVILEGES;<\/p>\n<p>\u9000\u51famysql<\/p>\n<p>mysql&gt;exit;<\/p>\n<p>\u5f00\u542f\u9632\u706b\u5899mysql3306\u7aef\u53e3\u7684\u5916\u90e8\u8bbf\u95ee<\/p>\n<p>CentOS\u5347\u7ea7\u52307\u4e4b\u540e\uff0c\u4f7f\u7528firewalld\u4ee3\u66ff\u4e86\u539f\u6765\u7684iptables\u3002\u4e0b\u9762\u8bb0\u5f55\u5982\u4f55\u4f7f\u7528firewalld\u5f00\u653eLinux\u7aef\u53e3<\/p>\n<p>&#8211;zone : \u4f5c\u7528\u57df\uff0c\u7f51\u7edc\u533a\u57df\u5b9a\u4e49\u4e86\u7f51\u7edc\u8fde\u63a5\u7684\u53ef\u4fe1\u7b49\u7ea7\u3002\u8fd9\u662f\u4e00\u4e2a\u4e00\u5bf9\u591a\u7684\u5173\u7cfb\uff0c\u8fd9\u610f\u5473\u7740\u4e00\u6b21\u8fde\u63a5\u53ef\u4ee5\u4ec5\u4ec5\u662f\u4e00\u4e2a\u533a\u57df\u7684\u4e00\u90e8\u5206\uff0c\u800c\u4e00\u4e2a\u533a\u57df\u53ef\u4ee5\u7528\u4e8e\u5f88\u591a\u8fde\u63a5<\/p>\n<p>&#8211;add-port : \u6dfb\u52a0\u7aef\u53e3\u4e0e\u901a\u4fe1\u534f\u8bae\uff0c\u683c\u5f0f\u4e3a\uff1a\u7aef\u53e3\/\u901a\u8baf\u534f\u8bae\uff0c\u534f\u8bae\u662ftcp \u6216 udp<\/p>\n<p>&#8211;permanent : \u6c38\u4e45\u751f\u6548\uff0c\u6ca1\u6709\u6b64\u53c2\u6570\u7cfb\u7edf\u91cd\u542f\u540e\u7aef\u53e3\u8bbf\u95ee\u5931\u6548<\/p>\n<p>firewall-cmd &#8211;zone=public &#8211;add-port=3306\/tcp &#8211;permanent<\/p>\n<p>\u91cd\u542f\u9632\u706b\u5899<\/p>\n<p>firewall-cmd &#8211;reload<\/p>\n","protected":false},"excerpt":{"rendered":"<p>1\u3001CentOS7\u7684yum\u6e90\u4e2d\u9ed8\u8ba4\u662f\u6ca1\u6709mysql\u7684\uff0c\u6211\u4eec\u5148\u4e0b\u8f7dmysql\u7684re&#8230;<br \/><a class=\"read-more-button\" href=\"https:\/\/freesilo.com\/?p=1144\">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":[13,18],"tags":[],"class_list":["post-1144","post","type-post","status-publish","format-standard","hentry","category-linux","category-mysql"],"_links":{"self":[{"href":"https:\/\/freesilo.com\/index.php?rest_route=\/wp\/v2\/posts\/1144","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=1144"}],"version-history":[{"count":1,"href":"https:\/\/freesilo.com\/index.php?rest_route=\/wp\/v2\/posts\/1144\/revisions"}],"predecessor-version":[{"id":1150,"href":"https:\/\/freesilo.com\/index.php?rest_route=\/wp\/v2\/posts\/1144\/revisions\/1150"}],"wp:attachment":[{"href":"https:\/\/freesilo.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1144"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/freesilo.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1144"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/freesilo.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1144"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}