{"id":28552,"date":"2023-08-02T15:37:41","date_gmt":"2023-06-13T21:56:06","guid":{"rendered":"https:\/\/www.silicloud.com\/zh\/blog\/%e5%9c%a8centos7%e4%b8%ad%e5%ae%89%e8%a3%85mariadb%e3%80%82\/"},"modified":"2025-08-12T08:49:56","modified_gmt":"2025-08-12T00:49:56","slug":"%e5%9c%a8centos7%e4%b8%ad%e5%ae%89%e8%a3%85mariadb%e3%80%82","status":"publish","type":"post","link":"https:\/\/www.silicloud.com\/zh\/blog\/%e5%9c%a8centos7%e4%b8%ad%e5%ae%89%e8%a3%85mariadb%e3%80%82\/","title":{"rendered":"\u5728CentOS7\u4e2d\u5b89\u88c5MariaDB"},"content":{"rendered":"<h1>\u8bf7\u63d0\u4f9b\u4ee5\u4e0b\u53c2\u8003<\/p>\n<h1>\u4f7f\u7528Yum\u8fdb\u884c\u5b89\u88c5\u3002<\/p>\n<pre class=\"post-pre\"><code># yum install mariadb mariadb-server\r\n\r\n\r\n\r\n\u8aad\u307f\u8fbc\u3093\u3060\u30d7\u30e9\u30b0\u30a4\u30f3:fastestmirror, langpacks\r\nbase                                                       | 3.6 kB  00:00:00\r\nepel\/x86_64\/metalink                                       | 5.8 kB  00:00:00\r\nepel                                                       | 4.3 kB  00:00:00\r\nextras                                                     | 3.4 kB  00:00:00\r\nupdates                                                    | 3.4 kB  00:00:00\r\n(1\/3): epel\/x86_64\/updateinfo                              | 719 kB  00:00:07\r\n(2\/3): updates\/7\/x86_64\/primary_db                         | 2.2 MB  00:00:22\r\n(3\/3): epel\/x86_64\/primary_db                              | 4.5 MB  00:00:33\r\nLoading mirror speeds from cached hostfile\r\n * base: ftp.iij.ad.jp\r\n * epel: ftp.riken.jp\r\n * extras: ftp.iij.ad.jp\r\n * updates: ftp.iij.ad.jp\r\n\u4f9d\u5b58\u6027\u306e\u89e3\u6c7a\u3092\u3057\u3066\u3044\u307e\u3059\r\n--&gt; \u30c8\u30e9\u30f3\u30b6\u30af\u30b7\u30e7\u30f3\u306e\u78ba\u8a8d\u3092\u5b9f\u884c\u3057\u3066\u3044\u307e\u3059\u3002\r\n---&gt; \u30d1\u30c3\u30b1\u30fc\u30b8 mariadb.x86_64 1:5.5.52-1.el7 \u3092 \u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\r\n--&gt; \u4f9d\u5b58\u6027\u306e\u51e6\u7406\u3092\u3057\u3066\u3044\u307e\u3059: mariadb-libs(x86-64) = 1:5.5.52-1.el7 \u306e\u30d1\u30c3\u30b1\u30fc\u30b8: 1:mariadb-5.5.52-1.el7.x86_64\r\n---&gt; \u30d1\u30c3\u30b1\u30fc\u30b8 mariadb-server.x86_64 1:5.5.52-1.el7 \u3092 \u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\r\n--&gt; \u4f9d\u5b58\u6027\u306e\u51e6\u7406\u3092\u3057\u3066\u3044\u307e\u3059: perl-DBI \u306e\u30d1\u30c3\u30b1\u30fc\u30b8: 1:mariadb-server-5.5.52-1.el7.x86_64\r\n--&gt; \u4f9d\u5b58\u6027\u306e\u51e6\u7406\u3092\u3057\u3066\u3044\u307e\u3059: perl-DBD-MySQL \u306e\u30d1\u30c3\u30b1\u30fc\u30b8: 1:mariadb-server-5.5.52-1.el7.x86_64\r\n--&gt; \u4f9d\u5b58\u6027\u306e\u51e6\u7406\u3092\u3057\u3066\u3044\u307e\u3059: perl(DBI) \u306e\u30d1\u30c3\u30b1\u30fc\u30b8: 1:mariadb-server-5.5.52-1.el7.x86_64\r\n--&gt; \u30c8\u30e9\u30f3\u30b6\u30af\u30b7\u30e7\u30f3\u306e\u78ba\u8a8d\u3092\u5b9f\u884c\u3057\u3066\u3044\u307e\u3059\u3002\r\n---&gt; \u30d1\u30c3\u30b1\u30fc\u30b8 mariadb-libs.x86_64 1:5.5.50-1.el7_2 \u3092 \u66f4\u65b0\r\n---&gt; \u30d1\u30c3\u30b1\u30fc\u30b8 mariadb-libs.x86_64 1:5.5.52-1.el7 \u3092 \u30a2\u30c3\u30d7\u30c7\u30fc\u30c8\r\n---&gt; \u30d1\u30c3\u30b1\u30fc\u30b8 perl-DBD-MySQL.x86_64 0:4.023-5.el7 \u3092 \u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\r\n---&gt; \u30d1\u30c3\u30b1\u30fc\u30b8 perl-DBI.x86_64 0:1.627-4.el7 \u3092 \u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\r\n--&gt; \u4f9d\u5b58\u6027\u306e\u51e6\u7406\u3092\u3057\u3066\u3044\u307e\u3059: perl(RPC::PlServer) &gt;= 0.2001 \u306e\u30d1\u30c3\u30b1\u30fc\u30b8: perl-DBI-1.627-4.el7.x86_64\r\n--&gt; \u4f9d\u5b58\u6027\u306e\u51e6\u7406\u3092\u3057\u3066\u3044\u307e\u3059: perl(RPC::PlClient) &gt;= 0.2000 \u306e\u30d1\u30c3\u30b1\u30fc\u30b8: perl-DBI-1.627-4.el7.x86_64\r\n--&gt; \u30c8\u30e9\u30f3\u30b6\u30af\u30b7\u30e7\u30f3\u306e\u78ba\u8a8d\u3092\u5b9f\u884c\u3057\u3066\u3044\u307e\u3059\u3002\r\n---&gt; \u30d1\u30c3\u30b1\u30fc\u30b8 perl-PlRPC.noarch 0:0.2020-14.el7 \u3092 \u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\r\n--&gt; \u4f9d\u5b58\u6027\u306e\u51e6\u7406\u3092\u3057\u3066\u3044\u307e\u3059: perl(Net::Daemon) &gt;= 0.13 \u306e\u30d1\u30c3\u30b1\u30fc\u30b8: perl-PlRPC-0.2020-14.el7.noarch\r\n--&gt; \u4f9d\u5b58\u6027\u306e\u51e6\u7406\u3092\u3057\u3066\u3044\u307e\u3059: perl(Net::Daemon::Test) \u306e\u30d1\u30c3\u30b1\u30fc\u30b8: perl-PlRPC-0.2020-14.el7.noarch\r\n--&gt; \u4f9d\u5b58\u6027\u306e\u51e6\u7406\u3092\u3057\u3066\u3044\u307e\u3059: perl(Net::Daemon::Log) \u306e\u30d1\u30c3\u30b1\u30fc\u30b8: perl-PlRPC-0.2020-14.el7.noarch\r\n--&gt; \u4f9d\u5b58\u6027\u306e\u51e6\u7406\u3092\u3057\u3066\u3044\u307e\u3059: perl(Compress::Zlib) \u306e\u30d1\u30c3\u30b1\u30fc\u30b8: perl-PlRPC-0.2020-14.el7.noarch\r\n--&gt; \u30c8\u30e9\u30f3\u30b6\u30af\u30b7\u30e7\u30f3\u306e\u78ba\u8a8d\u3092\u5b9f\u884c\u3057\u3066\u3044\u307e\u3059\u3002\r\n---&gt; \u30d1\u30c3\u30b1\u30fc\u30b8 perl-IO-Compress.noarch 0:2.061-2.el7 \u3092 \u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\r\n--&gt; \u4f9d\u5b58\u6027\u306e\u51e6\u7406\u3092\u3057\u3066\u3044\u307e\u3059: perl(Compress::Raw::Zlib) &gt;= 2.061 \u306e\u30d1\u30c3\u30b1\u30fc\u30b8: perl-IO-Compress-2.061-2.el7.noarch\r\n--&gt; \u4f9d\u5b58\u6027\u306e\u51e6\u7406\u3092\u3057\u3066\u3044\u307e\u3059: perl(Compress::Raw::Bzip2) &gt;= 2.061 \u306e\u30d1\u30c3\u30b1\u30fc\u30b8: perl-IO-Compress-2.061-2.el7.noarch\r\n---&gt; \u30d1\u30c3\u30b1\u30fc\u30b8 perl-Net-Daemon.noarch 0:0.48-5.el7 \u3092 \u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\r\n--&gt; \u30c8\u30e9\u30f3\u30b6\u30af\u30b7\u30e7\u30f3\u306e\u78ba\u8a8d\u3092\u5b9f\u884c\u3057\u3066\u3044\u307e\u3059\u3002\r\n---&gt; \u30d1\u30c3\u30b1\u30fc\u30b8 perl-Compress-Raw-Bzip2.x86_64 0:2.061-3.el7 \u3092 \u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\r\n---&gt; \u30d1\u30c3\u30b1\u30fc\u30b8 perl-Compress-Raw-Zlib.x86_64 1:2.061-4.el7 \u3092 \u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\r\n--&gt; \u4f9d\u5b58\u6027\u89e3\u6c7a\u3092\u7d42\u4e86\u3057\u307e\u3057\u305f\u3002\r\n\r\n\u4f9d\u5b58\u6027\u3092\u89e3\u6c7a\u3057\u307e\u3057\u305f\r\n\r\n==================================================================================\r\n Package                       \u30a2\u30fc\u30ad\u30c6\u30af\u30c1\u30e3\u30fc\r\n                                            \u30d0\u30fc\u30b8\u30e7\u30f3           \u30ea\u30dd\u30b8\u30c8\u30ea\u30fc\r\n                                                                             \u5bb9\u91cf\r\n==================================================================================\r\n\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u4e2d:\r\n mariadb                       x86_64       1:5.5.52-1.el7       base       8.7 M\r\n mariadb-server                x86_64       1:5.5.52-1.el7       base        11 M\r\n\u4f9d\u5b58\u6027\u95a2\u9023\u3067\u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3092\u3057\u307e\u3059:\r\n perl-Compress-Raw-Bzip2       x86_64       2.061-3.el7          base        32 k\r\n perl-Compress-Raw-Zlib        x86_64       1:2.061-4.el7        base        57 k\r\n perl-DBD-MySQL                x86_64       4.023-5.el7          base       140 k\r\n perl-DBI                      x86_64       1.627-4.el7          base       802 k\r\n perl-IO-Compress              noarch       2.061-2.el7          base       260 k\r\n perl-Net-Daemon               noarch       0.48-5.el7           base        51 k\r\n perl-PlRPC                    noarch       0.2020-14.el7        base        36 k\r\n\u4f9d\u5b58\u6027\u95a2\u9023\u3067\u306e\u66f4\u65b0\u3092\u3057\u307e\u3059:\r\n mariadb-libs                  x86_64       1:5.5.52-1.el7       base       761 k\r\n\r\n\u30c8\u30e9\u30f3\u30b6\u30af\u30b7\u30e7\u30f3\u306e\u8981\u7d04\r\n==================================================================================\r\n\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb  2 \u30d1\u30c3\u30b1\u30fc\u30b8 (+7 \u500b\u306e\u4f9d\u5b58\u95a2\u4fc2\u306e\u30d1\u30c3\u30b1\u30fc\u30b8)\r\n\u66f4\u65b0                       ( 1 \u500b\u306e\u4f9d\u5b58\u95a2\u4fc2\u306e\u30d1\u30c3\u30b1\u30fc\u30b8)\r\n\r\n\u7dcf\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u5bb9\u91cf: 22 M\r\nIs this ok [y\/d\/N]: y\r\nIs this ok [y\/d\/N]: y\r\nDownloading packages:\r\nDelta RPMs disabled because \/usr\/bin\/applydeltarpm not installed.\r\n(1\/10): perl-Compress-Raw-Zlib-2.061-4.el7.x86_64.rpm      |  57 kB  00:00:06\r\n(2\/10): perl-Compress-Raw-Bzip2-2.061-3.el7.x86_64.rpm     |  32 kB  00:00:08\r\n(3\/10): perl-DBD-MySQL-4.023-5.el7.x86_64.rpm              | 140 kB  00:00:04\r\n(4\/10): mariadb-libs-5.5.52-1.el7.x86_64.rpm               | 761 kB  00:00:12\r\n(5\/10): perl-Net-Daemon-0.48-5.el7.noarch.rpm              |  51 kB  00:00:01\r\n(6\/10): perl-PlRPC-0.2020-14.el7.noarch.rpm                |  36 kB  00:00:00\r\n(7\/10): perl-IO-Compress-2.061-2.el7.noarch.rpm            | 260 kB  00:00:06\r\n(8\/10): perl-DBI-1.627-4.el7.x86_64.rpm                    | 802 kB  00:00:14\r\n(9\/10): mariadb-5.5.52-1.el7.x86_64.rpm                    | 8.7 MB  00:01:28\r\n(10\/10): mariadb-server-5.5.52-1.el7.x86_64.rpm            |  11 MB  00:01:37\r\n----------------------------------------------------------------------------------\r\n\u5408\u8a08                                                 227 kB\/s |  22 MB  01:37\r\nRunning transaction check\r\nRunning transaction test\r\nTransaction test succeeded\r\nRunning transaction\r\n  \u66f4\u65b0\u3057\u307e\u3059              : 1:mariadb-libs-5.5.52-1.el7.x86_64               1\/11\r\n  \u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u4e2d          : 1:mariadb-5.5.52-1.el7.x86_64                    2\/11\r\n  \u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u4e2d          : perl-Net-Daemon-0.48-5.el7.noarch                3\/11\r\n  \u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u4e2d          : 1:perl-Compress-Raw-Zlib-2.061-4.el7.x86_64      4\/11\r\n  \u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u4e2d          : perl-Compress-Raw-Bzip2-2.061-3.el7.x86_64       5\/11\r\n  \u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u4e2d          : perl-IO-Compress-2.061-2.el7.noarch              6\/11\r\n  \u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u4e2d          : perl-PlRPC-0.2020-14.el7.noarch                  7\/11\r\n  \u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u4e2d          : perl-DBI-1.627-4.el7.x86_64                      8\/11\r\n  \u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u4e2d          : perl-DBD-MySQL-4.023-5.el7.x86_64                9\/11\r\n  \u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u4e2d          : 1:mariadb-server-5.5.52-1.el7.x86_64            10\/11\r\n  \u6574\u7406\u4e2d                  : 1:mariadb-libs-5.5.50-1.el7_2.x86_64            11\/11\r\n  \u691c\u8a3c\u4e2d                  : perl-Compress-Raw-Bzip2-2.061-3.el7.x86_64       1\/11\r\n  \u691c\u8a3c\u4e2d                  : 1:mariadb-5.5.52-1.el7.x86_64                    2\/11\r\n  \u691c\u8a3c\u4e2d                  : 1:mariadb-server-5.5.52-1.el7.x86_64             3\/11\r\n  \u691c\u8a3c\u4e2d                  : 1:mariadb-libs-5.5.52-1.el7.x86_64               4\/11\r\n  \u691c\u8a3c\u4e2d                  : perl-PlRPC-0.2020-14.el7.noarch                  5\/11\r\n  \u691c\u8a3c\u4e2d                  : 1:perl-Compress-Raw-Zlib-2.061-4.el7.x86_64      6\/11\r\n  \u691c\u8a3c\u4e2d                  : perl-Net-Daemon-0.48-5.el7.noarch                7\/11\r\n  \u691c\u8a3c\u4e2d                  : perl-DBI-1.627-4.el7.x86_64                      8\/11\r\n  \u691c\u8a3c\u4e2d                  : perl-IO-Compress-2.061-2.el7.noarch              9\/11\r\n  \u691c\u8a3c\u4e2d                  : perl-DBD-MySQL-4.023-5.el7.x86_64               10\/11\r\n  \u691c\u8a3c\u4e2d                  : 1:mariadb-libs-5.5.50-1.el7_2.x86_64            11\/11\r\n\r\n\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb:\r\n  mariadb.x86_64 1:5.5.52-1.el7        mariadb-server.x86_64 1:5.5.52-1.el7\r\n\r\n\u4f9d\u5b58\u6027\u95a2\u9023\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u307e\u3057\u305f:\r\n  perl-Compress-Raw-Bzip2.x86_64 0:2.061-3.el7\r\n  perl-Compress-Raw-Zlib.x86_64 1:2.061-4.el7\r\n  perl-DBD-MySQL.x86_64 0:4.023-5.el7\r\n  perl-DBI.x86_64 0:1.627-4.el7\r\n  perl-IO-Compress.noarch 0:2.061-2.el7\r\n  perl-Net-Daemon.noarch 0:0.48-5.el7\r\n  perl-PlRPC.noarch 0:0.2020-14.el7\r\n\r\n\u4f9d\u5b58\u6027\u3092\u66f4\u65b0\u3057\u307e\u3057\u305f:\r\n  mariadb-libs.x86_64 1:5.5.52-1.el7\r\n\r\n\u5b8c\u4e86\u3057\u307e\u3057\u305f!\r\n<\/code><\/pre>\n<h1>\u786e\u8ba4mariaDB\u7684\u5b58\u5728<\/p>\n<pre class=\"post-pre\"><code># rpm -qa | grep maria\r\n\r\n\r\nrpm -qa | grep maria\r\nmariadb-libs-5.5.52-1.el7.x86_64\r\nmariadb-5.5.52-1.el7.x86_64\r\nmariadb-server-5.5.52-1.el7.x86_64\r\n<\/code><\/pre>\n<h1>\u9a6c\u91cc\u4e9aDB\u7684\u8bbe\u7f6e\u6587\u4ef6MariaDB\u7684\u914d\u7f6e\u6587\u4ef6\u4f4d\u4e8e\/etc\/my.cnf\uff0c\u8be5\u6587\u4ef6\u4f1a\u5305\u542b\/etc\/my.cnf.d\u76ee\u5f55\u4e0b\u7684\u5176\u4ed6\u914d\u7f6e\u6587\u4ef6\u3002\u5728\u8fd9\u4e9b\u6587\u4ef6\u4e2d\uff0c\u6211\u4eec\u53ef\u4ee5\u7f16\u8f91\/etc\/my.cnf\u5e76\u8bbe\u7f6e\u5b57\u7b26\u7f16\u7801\u3002<\/p>\n<div><img decoding=\"async\" class=\"post-images\" title=\"\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8 2017-01-21 10.55.25.png\" src=\"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/657cfd0537434c4406bc1a3a\/8-0.png\" alt=\"\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8 2017-01-21 10.55.25.png\" \/><\/p>\n<pre class=\"post-pre\"><code>\r\ncharacter-set-server=utf8\r\n\r\n\/\/\u8ffd\u52a0\u7b87\u6240\r\n<\/code><\/pre>\n<div><img decoding=\"async\" class=\"post-images\" title=\"\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8 2017-01-21 10.58.58.png\" src=\"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/657cfd0537434c4406bc1a3a\/10-0.png\" alt=\"\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8 2017-01-21 10.58.58.png\" \/><\/p>\n<h1>\u4f7f\u7528systemctl\u547d\u4ee4\u542f\u7528mariadb\u3002\u5728\u4f7f\u7528systemctl\u547d\u4ee4\u4e4b\u524d\uff0c\u9700\u8981\u5148\u6fc0\u6d3bmariadb\u5e76\u542f\u52a8\u5b83\u3002\uff08\u82e5\u4e0d\u5148\u6fc0\u6d3b\uff0c\u5219\u65e0\u6cd5\u542f\u52a8\uff09<\/p>\n<pre class=\"post-pre\"><code># systemctl enable mariadb.service\r\n\r\nCreated symlink from \/etc\/systemd\/system\/multi-user.target.wants\/mariadb.service to \/usr\/lib\/systemd\/system\/mariadb.service.\r\n\r\n<\/code><\/pre>\n<h1>\u542f\u52a8MariaDB<\/p>\n<pre class=\"post-pre\"><code># systemctl start mariadb.service\r\n<\/code><\/pre>\n<h1>MariaDB\u7684\u521d\u59cb\u914d\u7f6e\u63a5\u4e0b\u6765\uff0c\u6211\u4eec\u5c06\u8fdb\u884cMariaDB\u7684\u521d\u59cb\u8bbe\u7f6e\u3002\u6839\u636e\u4ea4\u4e92\u5f0f\u8bbe\u7f6e\u547d\u4ee4\u8fdb\u884c\u64cd\u4f5c\u3002\u53ea\u9700\u5728\u8bbe\u7f6eroot\u5bc6\u7801\u5904\u8f93\u5165\uff0c\u5176\u4ed6\u5730\u65b9\u76f4\u63a5\u6309Enter\u5373\u53ef\u3002<\/p>\n<pre class=\"post-pre\"><code># mysql_secure_installation\r\n<\/code><\/pre>\n<h1>\u8bbe\u7f6e\u5bc6\u7801\u9700\u6c42<\/p>\n<pre class=\"post-pre\"><code>Enter current password for root (enter for none):\r\nOK, successfully used password, moving on...\r\n\r\nSetting the root password ensures that nobody can log into the MariaDB\r\nroot user without the proper authorisation.\r\n\r\nSet root password? [Y\/n] Y\r\nNew password:\r\nRe-enter new password:\r\nPassword updated successfully!\r\nReloading privilege tables..\r\n ... Success!\r\n\r\n\r\nBy default, a MariaDB installation has an anonymous user, allowing anyone\r\nto log into MariaDB without having to have a user account created for\r\nthem.  This is intended only for testing, and to make the installation\r\ngo a bit smoother.  You should remove them before moving into a\r\nproduction environment.\r\n<\/code><\/pre>\n<h1>\u4ee5\u540e\u4e0d\u8f93\u5165\u4efb\u4f55\u5185\u5bb9\uff0c\u6309\u4e0b\u56de\u8f66\u3002<\/p>\n<pre class=\"post-pre\"><code>\r\nRemove anonymous users? [Y\/n]\r\n ... Success!\r\n\r\nNormally, root should only be allowed to connect from 'localhost'.  This\r\nensures that someone cannot guess at the root password from the network.\r\n\r\nDisallow root login remotely? [Y\/n]\r\n ... Success!\r\n\r\nBy default, MariaDB comes with a database named 'test' that anyone can\r\naccess.  This is also intended only for testing, and should be removed\r\nbefore moving into a production environment.\r\n\r\nRemove test database and access to it? [Y\/n]\r\n - Dropping test database...\r\n ... Success!\r\n - Removing privileges on test database...\r\n ... Success!\r\n\r\nReloading the privilege tables will ensure that all changes made so far\r\nwill take effect immediately.\r\n\r\nReload privilege tables now? [Y\/n]\r\n ... Success!\r\n\r\nCleaning up...\r\n\r\nAll done!  If you've completed all of the above steps, your MariaDB\r\ninstallation should now be secure.\r\n\r\nThanks for using MariaDB!\r\n\r\n\r\n\r\n<\/code><\/pre>\n<h1>\u767b\u5f55MariaDB\u767b\u5f55MariaDB<\/p>\n<p>\u6211\u6b63\u5728\u4f7f\u7528\u6700\u521d\u8bbe\u7f6e\u7684root\u7528\u6237\u767b\u5f55\u3002<\/p>\n<pre class=\"post-pre\"><code># mysql -u root -p\r\n<\/code><\/pre>\n<h1>\u5728MariaDB\u4e2d\u521b\u5efa\u7528\u6237\u3002\u8981\u6267\u884c\u6570\u636e\u5e93\u64cd\u4f5c\uff0c\u8bf7\u6309\u7167\u4ee5\u4e0b\u65b9\u5f0f\u6267\u884c\u547d\u4ee4\u3002<\/p>\n<pre class=\"post-pre\"><code>mysql -u root -p\r\nEnter password:\r\nWelcome to the MariaDB monitor.  Commands end with ; or \\g.\r\nYour MariaDB connection id is 12\r\nServer version: 5.5.52-MariaDB MariaDB Server\r\n\r\nCopyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others.\r\n\r\nType 'help;' or '\\h' for help. Type '\\c' to clear the current input statement.\r\n\r\nMariaDB [(none)]&gt;\r\n<\/code><\/pre>\n<h1>\u663e\u793a\u521a\u5b89\u88c5\u540e\u7684\u7528\u6237\u5217\u8868\u7684SQL\u67e5\u8be2\u8bed\u53e5\u3002\u4ee5\u4e0b\u662f\u663e\u793a\u521d\u59cb\u5b89\u88c5\u540e\u7684\u7528\u6237\u5217\u8868\u7684SQL\u8bed\u53e5\u3002\u521d\u59cb\u60c5\u51b5\u4e0b\u53ea\u6709\u4e00\u4e2aroot\u7528\u6237\uff0c\u4f46\u662f\u4e3b\u673a\u540d\u53ef\u4ee5\u6709\u591a\u4e2a\u6ce8\u518c\u3002MariaDB\u7684\u7528\u6237\u7531&#8221;username@hostname&#8221;\u6765\u552f\u4e00\u8bc6\u522b\u3002\u7136\u800c\uff0c\u7531\u4e8e\u4e3b\u673a\u540d\u90fd\u662f\u81ea\u672c\u673a\uff0c\u6240\u4ee5\u88ab\u89c6\u4e3a\u4ece\u672c\u673a\u8fde\u63a5\u7684root\u7528\u6237\u3002<\/p>\n<pre class=\"post-pre\"><code>MariaDB [(none)]&gt;  select user,host,user from mysql.user;\r\n+------+-----------+------+\r\n| user | host      | user |\r\n+------+-----------+------+\r\n| root | 127.0.0.1 | root |\r\n| root | ::1       | root |\r\n| root | localhost | root |\r\n+------+-----------+------+\r\n3 rows in set (0.00 sec)\r\n<\/code><\/pre>\n<h1>\u4f7f\u7528MariaDB\u8fdb\u884c\u6570\u636e\u5e93\u64cd\u4f5c\u3002\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u521b\u5efa\u540d\u4e3atest\u7684\u6570\u636e\u5e93\u3002<\/p>\n<pre class=\"post-pre\"><code>\r\nMariaDB [(none)]&gt; create database test;\r\nQuery OK, 1 row affected (0.00 sec)\r\n<\/code><\/pre>\n<h1>\u6211\u4f1a\u786e\u8ba4\u5df2\u7ecf\u521b\u5efa\u7684\u6570\u636e\u5e93\u3002<\/p>\n<pre class=\"post-pre\"><code>\r\n\r\nMariaDB [(none)]&gt; show databases;\r\n+--------------------+\r\n| Database           |\r\n+--------------------+\r\n| information_schema |\r\n| mysql              |\r\n| performance_schema |\r\n| test               |\r\n+--------------------+\r\n4 rows in set (0.00 sec)\r\n<\/code><\/pre>\n<h1>\u6211\u5c06\u8fdb\u5165\u6307\u5b9a\u7684\u6570\u636e\u5e93\uff0c\u5e76\u5c1d\u8bd5\u521b\u5efa\u8868\u7b49\u64cd\u4f5c\u3002<\/p>\n<pre class=\"post-pre\"><code>MariaDB [(none)]&gt; use test;\r\nDatabase changed\r\nMariaDB [test]&gt;\r\n<\/code><\/pre>\n<pre class=\"post-pre\"><code>MariaDB [test]&gt; create table test(num int,name varchar(50));\r\nQuery OK, 0 rows affected (0.00 sec)\r\n<\/code><\/pre>\n<pre class=\"post-pre\"><code>MariaDB [test]&gt; show tables;\r\n+----------------+\r\n| Tables_in_test |\r\n+----------------+\r\n| test           |\r\n+----------------+\r\n1 row in set (0.00 sec)\r\n<\/code><\/pre>\n<h1>\u6211\u5c1d\u8bd5\u5411\u521b\u5efa\u7684\u8868\u683c\u4e2d\u6dfb\u52a0\u6570\u636e\u3002<br \/>\n\u5728test\u7684\u8868\u4e2d\u63d2\u5165\u503c\u4e3a&#8221;Unix\u7528\u62371&#8243;\u7684\u6570\u636e\u3002<\/p>\n<pre class=\"post-pre\"><code>MariaDB [test]&gt; insert into test values(1,'\u30e6\u30cb\u30c3\u30af\u30b9\u30e6\u30fc\u30b61');\r\nQuery OK, 1 row affected (0.00 sec)\r\n<\/code><\/pre>\n<h1>\u786e\u8ba4\u4e00\u4e0b\u8868\u683c\u4e2d\u662f\u5426\u586b\u5165\u4e86\u6570\u636e\u3002<\/p>\n<pre class=\"post-pre\"><code>MariaDB [test]&gt; select * from test;\r\n+------+---------------------------+\r\n| num  | name                      |\r\n+------+---------------------------+\r\n|    1 | \u30e6\u30cb\u30c3\u30af\u30b9\u30e6\u30fc\u30b61         |\r\n+------+---------------------------+\r\n1 row in set (0.00 sec)\r\n<\/code><\/pre>\n<h1>\u66f4\u65b0\u5df2\u6ce8\u518c\u7684\u6570\u636e<\/p>\n<pre class=\"post-pre\"><code>update test set name='\u30e6\u30cb\u30c3\u30af\u30b9\u30e6\u30fc\u30b610' where num=1;\r\nQuery OK, 1 row affected (0.00 sec)\r\nRows matched: 1  Changed: 1  Warnings: 0\r\n<\/code><\/pre>\n<pre class=\"post-pre\"><code>select * from test;\r\n+------+----------------------------+\r\n| num  | name                       |\r\n+------+----------------------------+\r\n|    1 | \u30e6\u30cb\u30c3\u30af\u30b9\u30e6\u30fc\u30b610         |\r\n+------+----------------------------+\r\n1 row in set (0.00 sec)\r\n<\/code><\/pre>\n<h1>\u5220\u9664\u5728\u8868\u4e2d\u6ce8\u518c\u7684\u6570\u636e\uff0c\u5e76\u786e\u8ba4\u5176\u5df2\u88ab\u5220\u9664\u3002<\/p>\n<pre class=\"post-pre\"><code>delete from test where num=1;\r\nQuery OK, 1 row affected (0.00 sec)\r\n<\/code><\/pre>\n<pre class=\"post-pre\"><code>select * from test;\r\nEmpty set (0.00 sec)\r\n<\/code><\/pre>\n<h1>\u8fdb\u4e00\u6b65\u5c1d\u8bd5\u5220\u9664\u6570\u636e\u8868\u672c\u8eab\u3002\u901a\u8fc7show\u547d\u4ee4\u9a8c\u8bc1\u786e\u4fdd\u5176\u4e3a\u7a7a\u3002<\/p>\n<pre class=\"post-pre\"><code>MariaDB [test]&gt; drop table test\r\n    -&gt; ;\r\nQuery OK, 0 rows affected (0.00 sec)\r\n<\/code><\/pre>\n<h1>\u5220\u9664DB\u672c\u8eab<\/p>\n<pre class=\"post-pre\"><code>ariaDB [test]&gt; drop database test;\r\nQuery OK, 0 rows affected (0.00 sec)\r\n\r\nMariaDB [(none)]&gt; show databases;\r\n+--------------------+\r\n| Database           |\r\n+--------------------+\r\n| information_schema |\r\n| mysql              |\r\n| performance_schema |\r\n+--------------------+\r\n3 rows in set (0.00 sec)\r\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u8bf7\u63d0\u4f9b\u4ee5\u4e0b\u53c2\u8003 \u4f7f\u7528Yum\u8fdb\u884c\u5b89\u88c5\u3002 # yum install mariadb mariadb-server [&hellip;]<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[227],"class_list":["post-28552","post","type-post","status-publish","format-standard","hentry","category-uncategorized","tag-227"],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v21.5 (Yoast SEO v21.5) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u5728CentOS7\u4e2d\u5b89\u88c5MariaDB - Blog - Silicon Cloud<\/title>\n<meta name=\"description\" content=\"\u5173\u4e8e\u5728CentOS7\u4e2d\u5b89\u88c5MariaDB\u7684\u6280\u672f\u6587\u7ae0\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.silicloud.com\/zh\/blog\/\u5728centos7\u4e2d\u5b89\u88c5mariadb\u3002\/\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u5728CentOS7\u4e2d\u5b89\u88c5MariaDB\" \/>\n<meta property=\"og:description\" content=\"\u5173\u4e8e\u5728CentOS7\u4e2d\u5b89\u88c5MariaDB\u7684\u6280\u672f\u6587\u7ae0\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.silicloud.com\/zh\/blog\/\u5728centos7\u4e2d\u5b89\u88c5mariadb\u3002\/\" \/>\n<meta property=\"og:site_name\" content=\"Blog - Silicon Cloud\" \/>\n<meta property=\"article:published_time\" content=\"2023-06-13T21:56:06+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-08-12T00:49:56+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/657cfd0537434c4406bc1a3a\/8-0.png\" \/>\n<meta name=\"author\" content=\"\u6e05, \u5b87\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"\u6e05, \u5b87\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/%e5%9c%a8centos7%e4%b8%ad%e5%ae%89%e8%a3%85mariadb%e3%80%82\/\",\"url\":\"https:\/\/www.silicloud.com\/zh\/blog\/%e5%9c%a8centos7%e4%b8%ad%e5%ae%89%e8%a3%85mariadb%e3%80%82\/\",\"name\":\"\u5728CentOS7\u4e2d\u5b89\u88c5MariaDB - Blog - Silicon Cloud\",\"isPartOf\":{\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#website\"},\"datePublished\":\"2023-06-13T21:56:06+00:00\",\"dateModified\":\"2025-08-12T00:49:56+00:00\",\"author\":{\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/1a6ecd3d914d22a5ac32791ffc1fbd8e\"},\"description\":\"\u5173\u4e8e\u5728CentOS7\u4e2d\u5b89\u88c5MariaDB\u7684\u6280\u672f\u6587\u7ae0\",\"breadcrumb\":{\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/%e5%9c%a8centos7%e4%b8%ad%e5%ae%89%e8%a3%85mariadb%e3%80%82\/#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.silicloud.com\/zh\/blog\/%e5%9c%a8centos7%e4%b8%ad%e5%ae%89%e8%a3%85mariadb%e3%80%82\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/%e5%9c%a8centos7%e4%b8%ad%e5%ae%89%e8%a3%85mariadb%e3%80%82\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.silicloud.com\/zh\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u5728CentOS7\u4e2d\u5b89\u88c5MariaDB\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#website\",\"url\":\"https:\/\/www.silicloud.com\/zh\/blog\/\",\"name\":\"Blog - Silicon Cloud\",\"description\":\"\",\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/1a6ecd3d914d22a5ac32791ffc1fbd8e\",\"name\":\"\u6e05, \u5b87\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/4b2016c18459a605fc469c7566608f5686491baa112d0871ee613f61b7210565?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/4b2016c18459a605fc469c7566608f5686491baa112d0871ee613f61b7210565?s=96&d=mm&r=g\",\"caption\":\"\u6e05, \u5b87\"},\"url\":\"https:\/\/www.silicloud.com\/zh\/blog\/author\/qingyu\/\"},{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/%e5%9c%a8centos7%e4%b8%ad%e5%ae%89%e8%a3%85mariadb%e3%80%82\/#local-main-organization-logo\",\"url\":\"\",\"contentUrl\":\"\",\"caption\":\"Blog - Silicon Cloud\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"\u5728CentOS7\u4e2d\u5b89\u88c5MariaDB - Blog - Silicon Cloud","description":"\u5173\u4e8e\u5728CentOS7\u4e2d\u5b89\u88c5MariaDB\u7684\u6280\u672f\u6587\u7ae0","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.silicloud.com\/zh\/blog\/\u5728centos7\u4e2d\u5b89\u88c5mariadb\u3002\/","og_locale":"zh_CN","og_type":"article","og_title":"\u5728CentOS7\u4e2d\u5b89\u88c5MariaDB","og_description":"\u5173\u4e8e\u5728CentOS7\u4e2d\u5b89\u88c5MariaDB\u7684\u6280\u672f\u6587\u7ae0","og_url":"https:\/\/www.silicloud.com\/zh\/blog\/\u5728centos7\u4e2d\u5b89\u88c5mariadb\u3002\/","og_site_name":"Blog - Silicon Cloud","article_published_time":"2023-06-13T21:56:06+00:00","article_modified_time":"2025-08-12T00:49:56+00:00","og_image":[{"url":"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/657cfd0537434c4406bc1a3a\/8-0.png"}],"author":"\u6e05, \u5b87","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"\u6e05, \u5b87","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"1 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.silicloud.com\/zh\/blog\/%e5%9c%a8centos7%e4%b8%ad%e5%ae%89%e8%a3%85mariadb%e3%80%82\/","url":"https:\/\/www.silicloud.com\/zh\/blog\/%e5%9c%a8centos7%e4%b8%ad%e5%ae%89%e8%a3%85mariadb%e3%80%82\/","name":"\u5728CentOS7\u4e2d\u5b89\u88c5MariaDB - Blog - Silicon Cloud","isPartOf":{"@id":"https:\/\/www.silicloud.com\/zh\/blog\/#website"},"datePublished":"2023-06-13T21:56:06+00:00","dateModified":"2025-08-12T00:49:56+00:00","author":{"@id":"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/1a6ecd3d914d22a5ac32791ffc1fbd8e"},"description":"\u5173\u4e8e\u5728CentOS7\u4e2d\u5b89\u88c5MariaDB\u7684\u6280\u672f\u6587\u7ae0","breadcrumb":{"@id":"https:\/\/www.silicloud.com\/zh\/blog\/%e5%9c%a8centos7%e4%b8%ad%e5%ae%89%e8%a3%85mariadb%e3%80%82\/#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.silicloud.com\/zh\/blog\/%e5%9c%a8centos7%e4%b8%ad%e5%ae%89%e8%a3%85mariadb%e3%80%82\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.silicloud.com\/zh\/blog\/%e5%9c%a8centos7%e4%b8%ad%e5%ae%89%e8%a3%85mariadb%e3%80%82\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.silicloud.com\/zh\/blog\/"},{"@type":"ListItem","position":2,"name":"\u5728CentOS7\u4e2d\u5b89\u88c5MariaDB"}]},{"@type":"WebSite","@id":"https:\/\/www.silicloud.com\/zh\/blog\/#website","url":"https:\/\/www.silicloud.com\/zh\/blog\/","name":"Blog - Silicon Cloud","description":"","inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/1a6ecd3d914d22a5ac32791ffc1fbd8e","name":"\u6e05, \u5b87","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/4b2016c18459a605fc469c7566608f5686491baa112d0871ee613f61b7210565?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/4b2016c18459a605fc469c7566608f5686491baa112d0871ee613f61b7210565?s=96&d=mm&r=g","caption":"\u6e05, \u5b87"},"url":"https:\/\/www.silicloud.com\/zh\/blog\/author\/qingyu\/"},{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.silicloud.com\/zh\/blog\/%e5%9c%a8centos7%e4%b8%ad%e5%ae%89%e8%a3%85mariadb%e3%80%82\/#local-main-organization-logo","url":"","contentUrl":"","caption":"Blog - Silicon Cloud"}]}},"_links":{"self":[{"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts\/28552","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/comments?post=28552"}],"version-history":[{"count":3,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts\/28552\/revisions"}],"predecessor-version":[{"id":111348,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts\/28552\/revisions\/111348"}],"wp:attachment":[{"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/media?parent=28552"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/categories?post=28552"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/tags?post=28552"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}