{"id":4952,"date":"2019-08-14T21:27:54","date_gmt":"2019-08-14T13:27:54","guid":{"rendered":"http:\/\/lrxjmw.cn\/?p=4952"},"modified":"2019-08-14T21:27:54","modified_gmt":"2019-08-14T13:27:54","slug":"centos7-use-official-yum-install-mysql","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/centos7-use-official-yum-install-mysql.html","title":{"rendered":"Centos7\u4e0a\u4f7f\u7528\u5b98\u65b9YUM\u6e90\u5b89\u88c5Mysql"},"content":{"rendered":"
\n

\u672c\u6587\u7531lrxjmw.cn\u56e2\u961f\u6210\u5458\u51af\u632f\u534e<\/span>\u6574\u7406\u53d1\u5e03\uff0c\u70b9\u6b64\u62a5\u540dLinux\u57f9\u8bad<\/a><\/span><\/strong>\u3002<\/p>\n<\/div>\n

1. \u4e0b\u8f7dmysql\u7684repo\u6e90<\/p>\n

$ wget http:\/\/repo.mysql.com\/mysql-community-release-el7-5.noarch.rpm<\/pre>\n

2. \u5b89\u88c5mysql-community-release-el7-5.noarch.rpm\u5305<\/p>\n

$ sudo rpm -ivh mysql-community-release-el7-5.noarch.rpm\r\n\u5b89\u88c5\u8fd9\u4e2a\u5305\u540e\uff0c\u4f1a\u83b7\u5f97\u4e24\u4e2amysql\u7684yum repo\u6e90\uff1a\r\n\/etc\/yum.repos.d\/mysql-community.repo\r\n\/etc\/yum.repos.d\/mysql-community-source.repo<\/pre>\n

3. \u5b89\u88c5mysql<\/p>\n

$ sudo yum install mysql-server<\/pre>\n

\u6839\u636e\u6b65\u9aa4\u5b89\u88c5\u5c31\u53ef\u4ee5\u4e86\uff0c\u4e0d\u8fc7\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u6ca1\u6709\u5bc6\u7801\uff0c\u9700\u8981\u91cd\u7f6e\u5bc6\u7801\u3002<\/p>\n

4. \u91cd\u7f6e\u5bc6\u7801<\/p>\n

\u91cd\u7f6e\u5bc6\u7801\u524d\uff0c\u9996\u5148\u8981\u767b\u5f55<\/p>\n

$ mysql -u root\r\n\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\uff1a\r\n\r\n$ sudo chown -R openscanner:openscanner \/var\/lib\/mysql\r\n\u7136\u540e\uff0c\u91cd\u542f\u670d\u52a1\uff1a\r\n\r\n$ service mysqld restart\r\n\r\n\u63a5\u4e0b\u6765\u767b\u5f55\u91cd\u7f6e\u5bc6\u7801\uff1a\r\n\r\n$ mysql -u root\r\nmysql > use mysql;\r\nmysql > update user set password=password(\u2018123456\u2018) where user=\u2018root\u2018;\r\nmysql > exit;<\/pre>\n

5. \u5f00\u653e3306\u7aef\u53e3<\/p>\n

$ sudo vim \/etc\/sysconfig\/iptables\r\n\u6dfb\u52a0\u4ee5\u4e0b\u5185\u5bb9\uff1a\r\n\r\n-A INPUT -p tcp -m state --state NEW -m tcp --dport 3306 -j ACCEPT\r\n\u4fdd\u5b58\u540e\u91cd\u542f\u9632\u706b\u5899\uff1a\r\n\r\n$ sudo service iptables restart<\/pre>\n

\u8fd9\u6837\u4ece\u5176\u5b83\u5ba2\u6237\u673a\u4e5f\u53ef\u4ee5\u8fde\u63a5\u4e0amysql\u670d\u52a1\u4e86\u3002<\/p>\n

\n

\u672c\u6587\u5730\u5740\uff1ahttp:\/\/lrxjmw.cn\/centos7-use-official-yum-install-mysql.html<\/a>\u7f16\u8f91\uff1a\u51af\u632f\u534e\uff0c\u5ba1\u6838\u5458\uff1a\u5f20\u5b8f\u5b87<\/span><\/p>\n<\/blockquote>\n","protected":false},"excerpt":{"rendered":"

1. \u4e0b\u8f7dmysql\u7684repo\u6e90 $ wget http:\/\/repo.mysql.com\/mysql-com […]<\/p>\n","protected":false},"author":317,"featured_media":4956,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-4952","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-thread"],"acf":[],"_links":{"self":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/4952","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/users\/317"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=4952"}],"version-history":[{"count":9,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/4952\/revisions"}],"predecessor-version":[{"id":13304,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/4952\/revisions\/13304"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/4956"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=4952"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=4952"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=4952"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}