{"id":43640,"date":"2024-10-06T01:31:34","date_gmt":"2024-10-05T17:31:34","guid":{"rendered":"https:\/\/server.hk\/cnblog\/43640\/"},"modified":"2024-10-06T01:31:34","modified_gmt":"2024-10-05T17:31:34","slug":"centos-7-minimal-%e4%b8%8b-mysql-%e7%9a%84%e5%8d%b8%e8%bc%89%e5%8f%8a%e5%ae%89%e8%a3%9d","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/43640\/","title":{"rendered":"CentOS 7 minimal \u4e0b MySQL \u7684\u5378\u8f09\u53ca\u5b89\u88dd"},"content":{"rendered":"<h1 id=\"centos-7-minimal-%e4%b8%8b-mysql-%e7%9a%84%e5%8d%b8%e8%bc%89%e5%8f%8a%e5%ae%89%e8%a3%9d-UQJQUqjZPR\">CentOS 7 Minimal \u4e0b MySQL \u7684\u5378\u8f09\u53ca\u5b89\u88dd<\/h1>\n<p>\u5728 CentOS 7 Minimal \u74b0\u5883\u4e2d\uff0cMySQL \u662f\u4e00\u500b\u6d41\u884c\u7684\u8cc7\u6599\u5eab\u7ba1\u7406\u7cfb\u7d71\uff0c\u5ee3\u6cdb\u61c9\u7528\u65bc\u5404\u7a2e\u61c9\u7528\u7a0b\u5f0f\u4e2d\u3002\u672c\u6587\u5c07\u8a73\u7d30\u4ecb\u7d39\u5982\u4f55\u5728 CentOS 7 Minimal \u74b0\u5883\u4e2d\u5378\u8f09\u53ca\u5b89\u88dd MySQL\uff0c\u5e6b\u52a9\u7528\u6236\u9806\u5229\u5b8c\u6210\u9019\u4e00\u904e\u7a0b\u3002<\/p>\n<h2 id=\"%e4%b8%80%e3%80%81%e5%8d%b8%e8%bc%89-mysql-UQJQUqjZPR\">\u4e00\u3001\u5378\u8f09 MySQL<\/h2>\n<p>\u5982\u679c\u60a8\u9700\u8981\u5378\u8f09\u5df2\u5b89\u88dd\u7684 MySQL\uff0c\u53ef\u4ee5\u6309\u7167\u4ee5\u4e0b\u6b65\u9a5f\u9032\u884c\uff1a<\/p>\n<ol>\n<li>\u9996\u5148\uff0c\u6aa2\u67e5 MySQL \u662f\u5426\u6b63\u5728\u904b\u884c\u3002\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u4f86\u78ba\u8a8d\uff1a<\/li>\n<pre><code>systemctl status mysqld<\/code><\/pre>\n<li>\u5982\u679c MySQL \u6b63\u5728\u904b\u884c\uff0c\u60a8\u9700\u8981\u5148\u505c\u6b62\u670d\u52d9\uff1a<\/li>\n<pre><code>sudo systemctl stop mysqld<\/code><\/pre>\n<li>\u63a5\u4e0b\u4f86\uff0c\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u5378\u8f09 MySQL\uff1a<\/li>\n<pre><code>sudo yum remove mysql mysql-server mysql-libs<\/code><\/pre>\n<li>\u70ba\u4e86\u6e05\u9664\u6240\u6709\u7684\u914d\u7f6e\u6587\u4ef6\u548c\u6578\u64da\uff0c\u60a8\u53ef\u4ee5\u522a\u9664 MySQL \u7684\u8cc7\u6599\u593e\uff1a<\/li>\n<pre><code>sudo rm -rf \/var\/lib\/mysql<\/code><\/pre>\n<li>\u6700\u5f8c\uff0c\u60a8\u53ef\u4ee5\u6aa2\u67e5\u662f\u5426\u5df2\u5b8c\u5168\u5378\u8f09 MySQL\uff1a<\/li>\n<pre><code>rpm -qa | grep mysql<\/code><\/pre>\n<\/ol>\n<h2 id=\"%e4%ba%8c%e3%80%81%e5%ae%89%e8%a3%9d-mysql-UQJQUqjZPR\">\u4e8c\u3001\u5b89\u88dd MySQL<\/h2>\n<p>\u5728\u5378\u8f09 MySQL \u5f8c\uff0c\u60a8\u53ef\u4ee5\u6309\u7167\u4ee5\u4e0b\u6b65\u9a5f\u91cd\u65b0\u5b89\u88dd MySQL\uff1a<\/p>\n<h3 id=\"1-%e6%b7%bb%e5%8a%a0-mysql-yum-repository-UQJQUqjZPR\">1. \u6dfb\u52a0 MySQL Yum Repository<\/h3>\n<p>\u9996\u5148\uff0c\u60a8\u9700\u8981\u6dfb\u52a0 MySQL \u7684 Yum Repository\u3002\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u4e0b\u8f09 MySQL \u7684 Yum Repository \u914d\u7f6e\u6587\u4ef6\uff1a<\/p>\n<pre><code>wget https:\/\/dev.mysql.com\/get\/mysql57-community-release-el7-11.noarch.rpm<\/code><\/pre>\n<p>\u7136\u5f8c\u5b89\u88dd\u8a72 RPM \u5305\uff1a<\/p>\n<pre><code>sudo rpm -ivh mysql57-community-release-el7-11.noarch.rpm<\/code><\/pre>\n<h3 id=\"2-%e5%ae%89%e8%a3%9d-mysql-UQJQUqjZPR\">2. \u5b89\u88dd MySQL<\/h3>\n<p>\u6dfb\u52a0\u5b8c Yum Repository \u5f8c\uff0c\u60a8\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-UQJQUqjZPR\">3. \u555f\u52d5 MySQL \u670d\u52d9<\/h3>\n<p>\u5b89\u88dd\u5b8c\u6210\u5f8c\uff0c\u555f\u52d5 MySQL \u670d\u52d9\uff1a<\/p>\n<pre><code>sudo systemctl start mysqld<\/code><\/pre>\n<p>\u70ba\u4e86\u78ba\u4fdd MySQL \u5728\u7cfb\u7d71\u555f\u52d5\u6642\u81ea\u52d5\u555f\u52d5\uff0c\u60a8\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-UQJQUqjZPR\">4. \u7372\u53d6\u81e8\u6642\u5bc6\u78bc<\/h3>\n<p>\u5b89\u88dd MySQL \u5f8c\uff0c\u7cfb\u7d71\u6703\u81ea\u52d5\u751f\u6210\u4e00\u500b\u81e8\u6642\u5bc6\u78bc\u3002\u60a8\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-%e9%85%8d%e7%bd%ae-mysql-UQJQUqjZPR\">5. \u914d\u7f6e MySQL<\/h3>\n<p>\u4f7f\u7528\u81e8\u6642\u5bc6\u78bc\u767b\u9304 MySQL\uff1a<\/p>\n<pre><code>mysql -u root -p<\/code><\/pre>\n<p>\u7cfb\u7d71\u6703\u63d0\u793a\u60a8\u8f38\u5165\u81e8\u6642\u5bc6\u78bc\u3002\u767b\u9304\u5f8c\uff0c\u5efa\u8b70\u60a8\u7acb\u5373\u66f4\u6539\u5bc6\u78bc\uff1a<\/p>\n<pre><code>ALTER USER 'root'@'localhost' IDENTIFIED BY '\u65b0\u5bc6\u78bc';<\/code><\/pre>\n<h2 id=\"%e7%b8%bd%e7%b5%90-UQJQUqjZPR\">\u7e3d\u7d50<\/h2>\n<p>\u5728 CentOS 7 Minimal \u74b0\u5883\u4e2d\uff0c\u5378\u8f09\u53ca\u5b89\u88dd MySQL \u7684\u904e\u7a0b\u76f8\u5c0d\u7c21\u55ae\u3002\u901a\u904e\u4e0a\u8ff0\u6b65\u9a5f\uff0c\u60a8\u53ef\u4ee5\u8f15\u9b06\u5730\u7ba1\u7406 MySQL \u7684\u5b89\u88dd\u8207\u5378\u8f09\u3002\u5982\u679c\u60a8\u9700\u8981\u66f4\u9ad8\u6548\u7684 <a href=\"https:\/\/server.hk\">VPS<\/a> \u89e3\u6c7a\u65b9\u6848\uff0cServer.HK \u63d0\u4f9b\u591a\u7a2e\u9078\u64c7\uff0c\u9069\u5408\u4e0d\u540c\u9700\u6c42\u7684\u7528\u6236\u3002\u7121\u8ad6\u662f <a href=\"https:\/\/server.hk\">\u9999\u6e2f\u4f3a\u670d\u5668<\/a> \u9084\u662f\u5176\u4ed6\u670d\u52d9\uff0c\u60a8\u90fd\u53ef\u4ee5\u5728\u6211\u5011\u7684\u7db2\u7ad9\u4e0a\u627e\u5230\u5408\u9069\u7684\u65b9\u6848\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Learn how to uninstall and install MySQL on CentOS 7 Minimal with step-by-step instructions for a smooth setup.<\/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-43640","post","type-post","status-publish","format-standard","hentry","category-setup-tutorials"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/43640","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=43640"}],"version-history":[{"count":1,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/43640\/revisions"}],"predecessor-version":[{"id":43641,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/43640\/revisions\/43641"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=43640"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=43640"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=43640"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}