{"id":43064,"date":"2024-10-04T15:23:09","date_gmt":"2024-10-04T07:23:09","guid":{"rendered":"https:\/\/server.hk\/cnblog\/43064\/"},"modified":"2024-10-04T15:23:09","modified_gmt":"2024-10-04T07:23:09","slug":"centos-7-%e5%ae%89%e8%a3%9d-mariadb-10-%e8%a9%b3%e8%a7%a3%e4%bb%a5%e5%8f%8a%e7%9b%b8%e9%97%9c%e9%85%8d%e7%bd%ae","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/43064\/","title":{"rendered":"CentOS 7 \u5b89\u88dd MariaDB 10 \u8a73\u89e3\u4ee5\u53ca\u76f8\u95dc\u914d\u7f6e"},"content":{"rendered":"<h1 id=\"centos-7-%e5%ae%89%e8%a3%9d-mariadb-10-%e8%a9%b3%e8%a7%a3%e4%bb%a5%e5%8f%8a%e7%9b%b8%e9%97%9c%e9%85%8d%e7%bd%ae-yGHClkthfP\">CentOS 7 \u5b89\u88dd MariaDB 10 \u8a73\u89e3\u4ee5\u53ca\u76f8\u95dc\u914d\u7f6e<\/h1>\n<p>MariaDB \u662f\u4e00\u500b\u958b\u6e90\u7684\u95dc\u806f\u5f0f\u8cc7\u6599\u5eab\u7ba1\u7406\u7cfb\u7d71\uff0c\u4f5c\u70ba MySQL \u7684\u4e00\u500b\u5206\u652f\uff0c\u56e0\u5176\u6027\u80fd\u548c\u5b89\u5168\u6027\u800c\u53d7\u5230\u5ee3\u6cdb\u4f7f\u7528\u3002\u672c\u6587\u5c07\u8a73\u7d30\u4ecb\u7d39\u5982\u4f55\u5728 CentOS 7 \u4e0a\u5b89\u88dd MariaDB 10 \u53ca\u5176\u76f8\u95dc\u914d\u7f6e\uff0c\u5e6b\u52a9\u7528\u6236\u66f4\u597d\u5730\u7ba1\u7406\u8cc7\u6599\u5eab\u3002<\/p>\n<h2 id=\"%e4%b8%80%e3%80%81%e5%ae%89%e8%a3%9d%e5%89%8d%e7%9a%84%e6%ba%96%e5%82%99-yGHClkthfP\">\u4e00\u3001\u5b89\u88dd\u524d\u7684\u6e96\u5099<\/h2>\n<p>\u5728\u958b\u59cb\u5b89\u88dd\u4e4b\u524d\uff0c\u8acb\u78ba\u4fdd\u60a8\u7684 CentOS 7 \u7cfb\u7d71\u5df2\u7d93\u66f4\u65b0\u5230\u6700\u65b0\u7248\u672c\u3002\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u9032\u884c\u66f4\u65b0\uff1a<\/p>\n<pre><code>sudo yum update -y<\/code><\/pre>\n<p>\u63a5\u4e0b\u4f86\uff0c\u60a8\u9700\u8981\u5b89\u88dd\u4e00\u4e9b\u5fc5\u8981\u7684\u5de5\u5177\uff0c\u4ee5\u4fbf\u65bc\u5f8c\u7e8c\u7684\u5b89\u88dd\u904e\u7a0b\uff1a<\/p>\n<pre><code>sudo yum install -y wget<\/code><\/pre>\n<h2 id=\"%e4%ba%8c%e3%80%81%e5%ae%89%e8%a3%9d-mariadb-10-yGHClkthfP\">\u4e8c\u3001\u5b89\u88dd MariaDB 10<\/h2>\n<h3 id=\"1-%e6%b7%bb%e5%8a%a0-mariadb-%e5%ad%98%e5%84%b2%e5%ba%ab-yGHClkthfP\">1. \u6dfb\u52a0 MariaDB \u5b58\u5132\u5eab<\/h3>\n<p>\u9996\u5148\uff0c\u60a8\u9700\u8981\u6dfb\u52a0 MariaDB \u7684\u5b98\u65b9\u5b58\u5132\u5eab\u3002\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u5275\u5efa\u4e00\u500b\u65b0\u7684 repo \u6587\u4ef6\uff1a<\/p>\n<pre><code>sudo vi \/etc\/yum.repos.d\/MariaDB.repo<\/code><\/pre>\n<p>\u5728\u6587\u4ef6\u4e2d\u6dfb\u52a0\u4ee5\u4e0b\u5167\u5bb9\uff1a<\/p>\n<pre><code>[mariadb]\nname = MariaDB\nbaseurl = http:\/\/yum.mariadb.org\/10.5\/centos7\/x86_64\ngpgkey=https:\/\/yum.mariadb.org\/RPM-GPG-KEY-MariaDB\ngpgcheck=1<\/code><\/pre>\n<h3 id=\"2-%e5%ae%89%e8%a3%9d-mariadb-yGHClkthfP\">2. \u5b89\u88dd MariaDB<\/h3>\n<p>\u6dfb\u52a0\u5b8c\u5b58\u5132\u5eab\u5f8c\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u5b89\u88dd MariaDB\uff1a<\/p>\n<pre><code>sudo yum install -y MariaDB-server MariaDB-client<\/code><\/pre>\n<h3 id=\"3-%e5%95%9f%e5%8b%95-mariadb-%e6%9c%8d%e5%8b%99-yGHClkthfP\">3. \u555f\u52d5 MariaDB \u670d\u52d9<\/h3>\n<p>\u5b89\u88dd\u5b8c\u6210\u5f8c\uff0c\u555f\u52d5 MariaDB \u670d\u52d9\u4e26\u8a2d\u7f6e\u5176\u5728\u7cfb\u7d71\u555f\u52d5\u6642\u81ea\u52d5\u555f\u52d5\uff1a<\/p>\n<pre><code>sudo systemctl start mariadb\nsudo systemctl enable mariadb<\/code><\/pre>\n<h2 id=\"%e4%b8%89%e3%80%81%e9%85%8d%e7%bd%ae-mariadb-yGHClkthfP\">\u4e09\u3001\u914d\u7f6e MariaDB<\/h2>\n<h3 id=\"1-%e5%ae%89%e5%85%a8%e9%85%8d%e7%bd%ae-yGHClkthfP\">1. \u5b89\u5168\u914d\u7f6e<\/h3>\n<p>\u70ba\u4e86\u63d0\u9ad8\u5b89\u5168\u6027\uff0c\u5efa\u8b70\u904b\u884c\u5b89\u5168\u8173\u672c\u4f86\u914d\u7f6e MariaDB\u3002\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u555f\u52d5\u5b89\u5168\u914d\u7f6e\u5411\u5c0e\uff1a<\/p>\n<pre><code>sudo mysql_secure_installation<\/code><\/pre>\n<p>\u5728\u6b64\u904e\u7a0b\u4e2d\uff0c\u60a8\u5c07\u88ab\u8981\u6c42\u8a2d\u7f6e root \u5bc6\u78bc\u3001\u522a\u9664\u533f\u540d\u7528\u6236\u3001\u7981\u6b62 root \u9060\u7a0b\u767b\u9304\u4ee5\u53ca\u522a\u9664\u6e2c\u8a66\u6578\u64da\u5eab\u7b49\u3002\u6839\u64da\u63d0\u793a\u9032\u884c\u64cd\u4f5c\u5373\u53ef\u3002<\/p>\n<h3 id=\"2-%e7%99%bb%e9%8c%84-mariadb-yGHClkthfP\">2. \u767b\u9304 MariaDB<\/h3>\n<p>\u5b8c\u6210\u5b89\u5168\u914d\u7f6e\u5f8c\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u767b\u9304 MariaDB\uff1a<\/p>\n<pre><code>mysql -u root -p<\/code><\/pre>\n<p>\u8f38\u5165\u60a8\u5728\u5b89\u5168\u914d\u7f6e\u904e\u7a0b\u4e2d\u8a2d\u7f6e\u7684\u5bc6\u78bc\uff0c\u5373\u53ef\u9032\u5165 MariaDB \u7684\u547d\u4ee4\u884c\u754c\u9762\u3002<\/p>\n<h3 id=\"3-%e5%89%b5%e5%bb%ba%e6%95%b8%e6%93%9a%e5%ba%ab%e5%92%8c%e7%94%a8%e6%88%b6-yGHClkthfP\">3. \u5275\u5efa\u6578\u64da\u5eab\u548c\u7528\u6236<\/h3>\n<p>\u5728 MariaDB \u4e2d\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u5275\u5efa\u65b0\u7684\u6578\u64da\u5eab\u548c\u7528\u6236\uff1a<\/p>\n<pre><code>CREATE DATABASE mydatabase;\nCREATE USER 'myuser'@'localhost' IDENTIFIED BY 'mypassword';\nGRANT ALL PRIVILEGES ON mydatabase.* TO 'myuser'@'localhost';\nFLUSH PRIVILEGES;<\/code><\/pre>\n<p>\u9019\u6a23\uff0c\u60a8\u5c31\u5275\u5efa\u4e86\u4e00\u500b\u540d\u70ba mydatabase \u7684\u6578\u64da\u5eab\u548c\u4e00\u500b\u540d\u70ba myuser \u7684\u7528\u6236\uff0c\u4e26\u6388\u4e88\u4e86\u8a72\u7528\u6236\u5c0d\u8a72\u6578\u64da\u5eab\u7684\u6240\u6709\u6b0a\u9650\u3002<\/p>\n<h2 id=\"%e5%9b%9b%e3%80%81%e7%b8%bd%e7%b5%90-yGHClkthfP\">\u56db\u3001\u7e3d\u7d50<\/h2>\n<p>\u672c\u6587\u8a73\u7d30\u4ecb\u7d39\u4e86\u5982\u4f55\u5728 CentOS 7 \u4e0a\u5b89\u88dd MariaDB 10 \u53ca\u5176\u57fa\u672c\u914d\u7f6e\u6b65\u9a5f\u3002\u901a\u904e\u9019\u4e9b\u6b65\u9a5f\uff0c\u60a8\u53ef\u4ee5\u8f15\u9b06\u5730\u8a2d\u7f6e\u548c\u7ba1\u7406\u60a8\u7684\u8cc7\u6599\u5eab\u3002\u82e5\u60a8\u9700\u8981\u66f4\u9ad8\u6548\u7684 <a href=\"https:\/\/server.hk\">VPS<\/a> \u89e3\u6c7a\u65b9\u6848\u4f86\u904b\u884c\u60a8\u7684\u61c9\u7528\uff0cServer.HK \u63d0\u4f9b\u591a\u7a2e\u9078\u64c7\uff0c\u6eff\u8db3\u4e0d\u540c\u9700\u6c42\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u8a73\u7d30\u6307\u5357\uff0c\u6559\u4f60\u5728 CentOS 7 \u4e0a\u5b89\u88dd MariaDB 10\uff0c\u4e26\u63d0\u4f9b\u76f8\u95dc\u914d\u7f6e\u6b65\u9a5f\uff0c\u52a9\u4f60\u8f15\u9b06\u642d\u5efa\u6578\u64da\u5eab\u74b0\u5883\u3002<\/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-43064","post","type-post","status-publish","format-standard","hentry","category-setup-tutorials"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/43064","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=43064"}],"version-history":[{"count":1,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/43064\/revisions"}],"predecessor-version":[{"id":43065,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/43064\/revisions\/43065"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=43064"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=43064"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=43064"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}