{"id":43898,"date":"2024-10-06T11:20:12","date_gmt":"2024-10-06T03:20:12","guid":{"rendered":"https:\/\/server.hk\/cnblog\/43898\/"},"modified":"2024-10-06T11:20:12","modified_gmt":"2024-10-06T03:20:12","slug":"centos-7-%e4%b8%8b%e5%bf%ab%e9%80%9f%e9%85%8d%e7%bd%ae-mariadb-10-%e5%85%b7%e9%ab%94%e6%96%b9%e6%b3%95","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/43898\/","title":{"rendered":"CentOS 7 \u4e0b\u5feb\u901f\u914d\u7f6e MariaDB 10 \u5177\u9ad4\u65b9\u6cd5"},"content":{"rendered":"<h1 id=\"centos-7-%e4%b8%8b%e5%bf%ab%e9%80%9f%e9%85%8d%e7%bd%ae-mariadb-10-%e5%85%b7%e9%ab%94%e6%96%b9%e6%b3%95-DdaoigENkT\">CentOS 7 \u4e0b\u5feb\u901f\u914d\u7f6e MariaDB 10 \u5177\u9ad4\u65b9\u6cd5<\/h1>\n<p>MariaDB \u662f\u4e00\u500b\u6d41\u884c\u7684\u958b\u6e90\u95dc\u806f\u6578\u64da\u5eab\u7ba1\u7406\u7cfb\u7d71\uff0c\u4f5c\u70ba MySQL \u7684\u4e00\u500b\u5206\u652f\uff0c\u63d0\u4f9b\u4e86\u66f4\u9ad8\u7684\u6027\u80fd\u548c\u66f4\u5f37\u7684\u529f\u80fd\u3002\u672c\u6587\u5c07\u4ecb\u7d39\u5982\u4f55\u5728 CentOS 7 \u4e0a\u5feb\u901f\u914d\u7f6e MariaDB 10\uff0c\u5e6b\u52a9\u7528\u6236\u8f15\u9b06\u642d\u5efa\u6578\u64da\u5eab\u74b0\u5883\u3002<\/p>\n<h2 id=\"%e5%89%8d%e6%9c%9f%e6%ba%96%e5%82%99-DdaoigENkT\">\u524d\u671f\u6e96\u5099<\/h2>\n<p>\u5728\u958b\u59cb\u4e4b\u524d\uff0c\u78ba\u4fdd\u4f60\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\u5b89\u88dd\u4e00\u4e9b\u5fc5\u8981\u7684\u5de5\u5177\uff1a<\/p>\n<pre><code>sudo yum install -y wget<\/code><\/pre>\n<h2 id=\"%e5%ae%89%e8%a3%9d-mariadb-10-DdaoigENkT\">\u5b89\u88dd MariaDB 10<\/h2>\n<p>MariaDB \u7684\u5b98\u65b9\u6e90\u4e26\u4e0d\u5305\u542b\u5728 CentOS \u7684\u9ed8\u8a8d\u6e90\u4e2d\uff0c\u56e0\u6b64\u9700\u8981\u624b\u52d5\u6dfb\u52a0 MariaDB \u7684 Yum \u5b58\u5132\u5eab\u3002\u9996\u5148\uff0c\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\ngpgcheck = 1\ngpgkey = https:\/\/yum.mariadb.org\/RPM-GPG-KEY-MariaDB\n<\/code><\/pre>\n<p>\u4fdd\u5b58\u4e26\u9000\u51fa\u7de8\u8f2f\u5668\u5f8c\uff0c\u57f7\u884c\u4ee5\u4e0b\u547d\u4ee4\u5b89\u88dd MariaDB\uff1a<\/p>\n<pre><code>sudo yum install -y MariaDB-server MariaDB-client<\/code><\/pre>\n<h2 id=\"%e5%95%9f%e5%8b%95-mariadb-%e6%9c%8d%e5%8b%99-DdaoigENkT\">\u555f\u52d5 MariaDB \u670d\u52d9<\/h2>\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=\"%e5%ae%89%e5%85%a8%e9%85%8d%e7%bd%ae-DdaoigENkT\">\u5b89\u5168\u914d\u7f6e<\/h2>\n<p>\u70ba\u4e86\u63d0\u9ad8 MariaDB \u7684\u5b89\u5168\u6027\uff0c\u5efa\u8b70\u904b\u884c\u5b89\u5168\u8173\u672c\u4f86\u9032\u884c\u57fa\u672c\u914d\u7f6e\uff1a<\/p>\n<pre><code>sudo mysql_secure_installation<\/code><\/pre>\n<p>\u9019\u500b\u8173\u672c\u6703\u5f15\u5c0e\u4f60\u5b8c\u6210\u4ee5\u4e0b\u5e7e\u500b\u6b65\u9a5f\uff1a<\/p>\n<ul>\n<li>\u8a2d\u7f6e root \u5bc6\u78bc<\/li>\n<li>\u522a\u9664\u533f\u540d\u7528\u6236<\/li>\n<li>\u7981\u6b62 root \u9060\u7a0b\u767b\u9304<\/li>\n<li>\u522a\u9664\u6e2c\u8a66\u6578\u64da\u5eab<\/li>\n<li>\u91cd\u65b0\u52a0\u8f09\u6b0a\u9650\u8868<\/li>\n<\/ul>\n<h2 id=\"%e9%80%a3%e6%8e%a5%e5%88%b0-mariadb-DdaoigENkT\">\u9023\u63a5\u5230 MariaDB<\/h2>\n<p>\u5b8c\u6210\u5b89\u5168\u914d\u7f6e\u5f8c\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u9023\u63a5\u5230 MariaDB\uff1a<\/p>\n<pre><code>mysql -u root -p<\/code><\/pre>\n<p>\u8f38\u5165\u4f60\u5728\u5b89\u5168\u914d\u7f6e\u904e\u7a0b\u4e2d\u8a2d\u7f6e\u7684 root \u5bc6\u78bc\uff0c\u5373\u53ef\u9032\u5165 MariaDB \u7684\u547d\u4ee4\u884c\u754c\u9762\u3002<\/p>\n<h2 id=\"%e5%89%b5%e5%bb%ba%e6%95%b8%e6%93%9a%e5%ba%ab%e5%92%8c%e7%94%a8%e6%88%b6-DdaoigENkT\">\u5275\u5efa\u6578\u64da\u5eab\u548c\u7528\u6236<\/h2>\n<p>\u5728 MariaDB \u4e2d\u5275\u5efa\u6578\u64da\u5eab\u548c\u7528\u6236\u7684\u57fa\u672c\u547d\u4ee4\u5982\u4e0b\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\u4e9b\u547d\u4ee4\u5c07\u5275\u5efa\u4e00\u500b\u540d\u70ba mydatabase \u7684\u6578\u64da\u5eab\uff0c\u4e26\u5275\u5efa\u4e00\u500b\u7528\u6236 myuser\uff0c\u8a72\u7528\u6236\u64c1\u6709\u5c0d\u8a72\u6578\u64da\u5eab\u7684\u6240\u6709\u6b0a\u9650\u3002<\/p>\n<h2 id=\"%e7%b8%bd%e7%b5%90-DdaoigENkT\">\u7e3d\u7d50<\/h2>\n<p>\u672c\u6587\u4ecb\u7d39\u4e86\u5982\u4f55\u5728 CentOS 7 \u4e0a\u5feb\u901f\u914d\u7f6e MariaDB 10\uff0c\u5305\u62ec\u5b89\u88dd\u3001\u555f\u52d5\u3001\u914d\u7f6e\u5b89\u5168\u6027\u4ee5\u53ca\u5275\u5efa\u6578\u64da\u5eab\u548c\u7528\u6236\u7684\u5177\u9ad4\u6b65\u9a5f\u3002\u9019\u4e9b\u6b65\u9a5f\u5c07\u5e6b\u52a9\u7528\u6236\u5feb\u901f\u642d\u5efa\u4e00\u500b\u5b89\u5168\u4e14\u9ad8\u6548\u7684\u6578\u64da\u5eab\u74b0\u5883\u3002\u5982\u679c\u4f60\u9700\u8981\u66f4\u9ad8\u6548\u7684 <a href=\"https:\/\/server.hk\">VPS<\/a> \u89e3\u6c7a\u65b9\u6848\u4f86\u904b\u884c\u4f60\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>\u5feb\u901f\u914d\u7f6e CentOS 7 \u4e0a\u7684 MariaDB 10\uff0c\u63d0\u4f9b\u5177\u9ad4\u6b65\u9a5f\u548c\u6280\u5de7\uff0c\u52a9\u60a8\u8f15\u9b06\u642d\u5efa\u9ad8\u6548\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-43898","post","type-post","status-publish","format-standard","hentry","category-setup-tutorials"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/43898","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=43898"}],"version-history":[{"count":1,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/43898\/revisions"}],"predecessor-version":[{"id":43899,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/43898\/revisions\/43899"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=43898"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=43898"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=43898"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}