{"id":42880,"date":"2024-10-04T07:41:32","date_gmt":"2024-10-03T23:41:32","guid":{"rendered":"https:\/\/server.hk\/cnblog\/42880\/"},"modified":"2024-10-04T07:41:32","modified_gmt":"2024-10-03T23:41:32","slug":"centos-7-0-%e4%b8%8b-yum-%e5%ae%89%e8%a3%9d-mysql-%e5%8f%8a%e4%bd%bf%e7%94%a8%e9%81%87%e5%88%b0%e5%95%8f%e9%a1%8c","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/42880\/","title":{"rendered":"CentOS 7.0 \u4e0b yum \u5b89\u88dd MySQL \u53ca\u4f7f\u7528\u9047\u5230\u554f\u984c"},"content":{"rendered":"<h1 id=\"centos-7-0-%e4%b8%8b-yum-%e5%ae%89%e8%a3%9d-mysql-%e5%8f%8a%e4%bd%bf%e7%94%a8%e9%81%87%e5%88%b0%e5%95%8f%e9%a1%8c-IKJoTkdHzv\">CentOS 7.0 \u4e0b yum \u5b89\u88dd MySQL \u53ca\u4f7f\u7528\u9047\u5230\u554f\u984c<\/h1>\n<p>\u5728 CentOS 7.0 \u7cfb\u7d71\u4e2d\uff0c\u4f7f\u7528 <code>yum<\/code> \u5b89\u88dd MySQL \u662f\u4e00\u500b\u76f8\u5c0d\u7c21\u55ae\u7684\u904e\u7a0b\u3002\u7136\u800c\uff0c\u5728\u5b89\u88dd\u548c\u4f7f\u7528\u904e\u7a0b\u4e2d\uff0c\u4f7f\u7528\u8005\u53ef\u80fd\u6703\u9047\u5230\u4e00\u4e9b\u554f\u984c\u3002\u672c\u6587\u5c07\u8a73\u7d30\u4ecb\u7d39\u5982\u4f55\u5728 CentOS 7.0 \u4e0a\u5b89\u88dd MySQL\uff0c\u4e26\u63a2\u8a0e\u53ef\u80fd\u9047\u5230\u7684\u554f\u984c\u53ca\u5176\u89e3\u6c7a\u65b9\u6848\u3002<\/p>\n<h2 id=\"%e5%ae%89%e8%a3%9d-mysql-%e7%9a%84%e6%ad%a5%e9%a9%9f-IKJoTkdHzv\">\u5b89\u88dd MySQL \u7684\u6b65\u9a5f<\/h2>\n<p>\u9996\u5148\uff0c\u78ba\u4fdd\u4f60\u7684\u7cfb\u7d71\u5df2\u7d93\u66f4\u65b0\u5230\u6700\u65b0\u7248\u672c\u3002\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u4f86\u66f4\u65b0\u7cfb\u7d71\uff1a<\/p>\n<pre><code>sudo yum update<\/code><\/pre>\n<p>\u63a5\u4e0b\u4f86\uff0c\u5b89\u88dd MySQL \u7684\u6b65\u9a5f\u5982\u4e0b\uff1a<\/p>\n<h3 id=\"1-%e6%b7%bb%e5%8a%a0-mysql-%e5%ad%98%e5%84%b2%e5%ba%ab-IKJoTkdHzv\">1. \u6dfb\u52a0 MySQL \u5b58\u5132\u5eab<\/h3>\n<p>\u5728\u5b89\u88dd MySQL \u4e4b\u524d\uff0c\u9700\u8981\u6dfb\u52a0 MySQL \u7684\u5b98\u65b9\u5b58\u5132\u5eab\u3002\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u4f86\u4e0b\u8f09\u4e26\u5b89\u88dd MySQL \u5b58\u5132\u5eab\uff1a<\/p>\n<pre><code>sudo rpm -Uvh https:\/\/repo.mysql.com\/mysql57-community-release-el7-11.noarch.rpm<\/code><\/pre>\n<h3 id=\"2-%e5%ae%89%e8%a3%9d-mysql-IKJoTkdHzv\">2. \u5b89\u88dd MySQL<\/h3>\n<p>\u6dfb\u52a0\u5b58\u5132\u5eab\u5f8c\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u5b89\u88dd MySQL\uff1a<\/p>\n<pre><code>sudo yum install mysql-community-server<\/code><\/pre>\n<h3 id=\"3-%e5%95%9f%e5%8b%95-mysql-%e6%9c%8d%e5%8b%99-IKJoTkdHzv\">3. \u555f\u52d5 MySQL \u670d\u52d9<\/h3>\n<p>\u5b89\u88dd\u5b8c\u6210\u5f8c\uff0c\u9700\u8981\u555f\u52d5 MySQL \u670d\u52d9\uff1a<\/p>\n<pre><code>sudo systemctl start mysqld<\/code><\/pre>\n<p>\u540c\u6642\uff0c\u70ba\u4e86\u78ba\u4fdd MySQL \u5728\u7cfb\u7d71\u555f\u52d5\u6642\u81ea\u52d5\u555f\u52d5\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<pre><code>sudo systemctl enable mysqld<\/code><\/pre>\n<h3 id=\"4-%e7%8d%b2%e5%8f%96%e8%87%a8%e6%99%82%e5%af%86%e7%a2%bc-IKJoTkdHzv\">4. \u7372\u53d6\u81e8\u6642\u5bc6\u78bc<\/h3>\n<p>\u5b89\u88dd\u5b8c\u6210\u5f8c\uff0cMySQL \u6703\u81ea\u52d5\u751f\u6210\u4e00\u500b\u81e8\u6642\u5bc6\u78bc\u3002\u53ef\u4ee5\u901a\u904e\u4ee5\u4e0b\u547d\u4ee4\u67e5\u770b\u8a72\u5bc6\u78bc\uff1a<\/p>\n<pre><code>sudo grep 'temporary password' \/var\/log\/mysqld.log<\/code><\/pre>\n<h3 id=\"5-%e8%a8%ad%e7%bd%ae-mysql-%e5%af%86%e7%a2%bc-IKJoTkdHzv\">5. \u8a2d\u7f6e MySQL \u5bc6\u78bc<\/h3>\n<p>\u4f7f\u7528\u81e8\u6642\u5bc6\u78bc\u767b\u9304 MySQL\uff0c\u4e26\u6839\u64da\u63d0\u793a\u8a2d\u7f6e\u65b0\u5bc6\u78bc\uff1a<\/p>\n<pre><code>mysql -u root -p<\/code><\/pre>\n<h2 id=\"%e5%b8%b8%e8%a6%8b%e5%95%8f%e9%a1%8c%e5%8f%8a%e8%a7%a3%e6%b1%ba%e6%96%b9%e6%a1%88-IKJoTkdHzv\">\u5e38\u898b\u554f\u984c\u53ca\u89e3\u6c7a\u65b9\u6848<\/h2>\n<h3 id=\"1-%e5%ae%89%e8%a3%9d%e9%81%8e%e7%a8%8b%e4%b8%ad%e5%87%ba%e7%8f%be%e4%be%9d%e8%b3%b4%e6%80%a7%e5%95%8f%e9%a1%8c-IKJoTkdHzv\">1. \u5b89\u88dd\u904e\u7a0b\u4e2d\u51fa\u73fe\u4f9d\u8cf4\u6027\u554f\u984c<\/h3>\n<p>\u5728\u5b89\u88dd MySQL \u6642\uff0c\u53ef\u80fd\u6703\u9047\u5230\u4f9d\u8cf4\u6027\u554f\u984c\u3002\u9019\u901a\u5e38\u662f\u56e0\u70ba\u7cfb\u7d71\u4e2d\u7f3a\u5c11\u67d0\u4e9b\u5fc5\u8981\u7684\u5305\u3002\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u4f86\u89e3\u6c7a\u4f9d\u8cf4\u6027\u554f\u984c\uff1a<\/p>\n<pre><code>sudo yum install -y epel-release<\/code><\/pre>\n<p>\u7136\u5f8c\u518d\u6b21\u5617\u8a66\u5b89\u88dd MySQL\u3002<\/p>\n<h3 id=\"2-mysql-%e6%9c%8d%e5%8b%99%e7%84%a1%e6%b3%95%e5%95%9f%e5%8b%95-IKJoTkdHzv\">2. MySQL \u670d\u52d9\u7121\u6cd5\u555f\u52d5<\/h3>\n<p>\u5982\u679c MySQL \u670d\u52d9\u7121\u6cd5\u555f\u52d5\uff0c\u53ef\u4ee5\u6aa2\u67e5\u65e5\u8a8c\u6587\u4ef6\u4ee5\u7372\u53d6\u66f4\u591a\u4fe1\u606f\uff1a<\/p>\n<pre><code>sudo journalctl -xe<\/code><\/pre>\n<p>\u6839\u64da\u65e5\u8a8c\u4e2d\u7684\u932f\u8aa4\u4fe1\u606f\u9032\u884c\u76f8\u61c9\u7684\u8abf\u6574\uff0c\u4f8b\u5982\u6aa2\u67e5\u914d\u7f6e\u6587\u4ef6\u6216\u6aa2\u67e5\u7aef\u53e3\u662f\u5426\u88ab\u4f54\u7528\u3002<\/p>\n<h3 id=\"3-%e7%99%bb%e9%8c%84%e6%99%82%e5%87%ba%e7%8f%be%e5%af%86%e7%a2%bc%e9%8c%af%e8%aa%a4-IKJoTkdHzv\">3. \u767b\u9304\u6642\u51fa\u73fe\u5bc6\u78bc\u932f\u8aa4<\/h3>\n<p>\u5982\u679c\u5728\u767b\u9304\u6642\u51fa\u73fe\u5bc6\u78bc\u932f\u8aa4\uff0c\u8acb\u78ba\u4fdd\u4f7f\u7528\u7684\u662f\u6b63\u78ba\u7684\u7528\u6236\u540d\u548c\u5bc6\u78bc\u3002\u5982\u679c\u5fd8\u8a18\u4e86\u5bc6\u78bc\uff0c\u53ef\u4ee5\u901a\u904e\u91cd\u7f6e\u5bc6\u78bc\u4f86\u89e3\u6c7a\uff1a<\/p>\n<pre><code>SET PASSWORD FOR 'root'@'localhost' = PASSWORD('\u65b0\u5bc6\u78bc');<\/code><\/pre>\n<h2 id=\"%e7%b8%bd%e7%b5%90-IKJoTkdHzv\">\u7e3d\u7d50<\/h2>\n<p>\u5728 CentOS 7.0 \u4e0a\u5b89\u88dd MySQL \u662f\u4e00\u500b\u76f8\u5c0d\u7c21\u55ae\u7684\u904e\u7a0b\uff0c\u4f46\u5728\u4f7f\u7528\u904e\u7a0b\u4e2d\u53ef\u80fd\u6703\u9047\u5230\u4e00\u4e9b\u554f\u984c\u3002\u901a\u904e\u672c\u6587\u63d0\u4f9b\u7684\u6b65\u9a5f\u548c\u89e3\u6c7a\u65b9\u6848\uff0c\u4f7f\u7528\u8005\u53ef\u4ee5\u66f4\u8f15\u9b06\u5730\u5b8c\u6210\u5b89\u88dd\u4e26\u89e3\u6c7a\u5e38\u898b\u554f\u984c\u3002\u5982\u679c\u60a8\u9700\u8981\u66f4\u9ad8\u6548\u7684\u670d\u52d9\uff0c\u8003\u616e\u4f7f\u7528\u6211\u5011\u7684 <a href=\"https:\/\/server.hk\">\u9999\u6e2fVPS<\/a> \u89e3\u6c7a\u65b9\u6848\uff0c\u63d0\u4f9b\u7a69\u5b9a\u7684\u4f3a\u670d\u5668\u74b0\u5883\u4ee5\u652f\u6301\u60a8\u7684\u61c9\u7528\u3002\u7121\u8ad6\u662f <a href=\"https:\/\/server.hk\">\u4e91\u4f3a\u670d\u5668<\/a> \u9084\u662f\u5176\u4ed6\u670d\u52d9\uff0c\u6211\u5011\u90fd\u80fd\u6eff\u8db3\u60a8\u7684\u9700\u6c42\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Learn how to install MySQL on CentOS 7.0 using yum and troubleshoot common issues encountered during the process.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4924],"tags":[],"class_list":["post-42880","post","type-post","status-publish","format-standard","hentry","category-setup-tutorials"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/42880","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/comments?post=42880"}],"version-history":[{"count":1,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/42880\/revisions"}],"predecessor-version":[{"id":42881,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/42880\/revisions\/42881"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=42880"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=42880"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=42880"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}