{"id":4124,"date":"2022-03-09T09:47:15","date_gmt":"2022-03-09T01:47:15","guid":{"rendered":"http:\/\/www.ylicloud.com\/?p=4124"},"modified":"2022-03-09T09:47:15","modified_gmt":"2022-03-09T01:47:15","slug":"%e5%9c%a8-centos-7-%e4%b8%8a%e5%ae%89%e8%a3%85-mariadb-%e7%9a%84-2-%e7%a7%8d%e6%96%b9%e6%b3%95","status":"publish","type":"post","link":"http:\/\/www.yliyun.com\/2022\/03\/09\/%e5%9c%a8-centos-7-%e4%b8%8a%e5%ae%89%e8%a3%85-mariadb-%e7%9a%84-2-%e7%a7%8d%e6%96%b9%e6%b3%95\/","title":{"rendered":"\u5728 CentOS 7 \u4e0a\u5b89\u88c5 MariaDB \u7684 2 \u79cd\u65b9\u6cd5"},"content":{"rendered":"\n

MariaDB \u662f\u4e00\u4e2a\u6d41\u884c\u7684\u5f00\u6e90 SQL \u6570\u636e\u5e93\u7ba1\u7406\u7cfb\u7edf\uff0c\u5b83\u662f MySQL \u7684\u4e00\u4e2a\u5206\u652f\u548c\u76f4\u63a5\u66ff\u4ee3\u54c1\u3002\u81ea Oracle \u6536\u8d2d MySQL \u4ee5\u6765\uff0cMariaDB \u6210\u4e3a\u5f00\u6e90\u793e\u533a\u9996\u9009\u7684\u6570\u636e\u5e93\u7cfb\u7edf\u3002MariaDB \u901a\u8fc7\u66f4\u5feb\u7684\u590d\u5236\u901f\u5ea6\u3001\u66f4\u4e25\u683c\u7684\u5b89\u5168\u63aa\u65bd\u548c\u989d\u5916\u7684\u5b58\u50a8\u5f15\u64ce\u63d0\u4f9b\u4e86\u6539\u8fdb\u7684\u6027\u80fd\uff0c\u8fd8\u6709\u4e00\u4e9b\u597d\u5904\u3002<\/p>\n\n\n\n

\u5728\u672c\u6307\u5357\u4e2d\uff0c\u60a8\u5c06\u5b66\u4e60\u5982\u4f55\u5728 CentOS 7 \u4e0a\u5b89\u88c5 MariaDB\u3002<\/p>\n\n\n\n

\u6709\u4e24\u79cd\u5b89\u88c5 MariaDB \u670d\u52a1\u5668\u7684\u65b9\u6cd5\u3002\u60a8\u53ef\u4ee5\u5b89\u88c5 CentOS 7 \u5b58\u50a8\u5e93\u4e2d\u53ef\u7528\u7684\u9ed8\u8ba4\u7248\u672c\uff0c\u4e5f\u53ef\u4ee5\u901a\u8fc7\u624b\u52a8\u6dfb\u52a0 MariaDB \u5b58\u50a8\u5e93\u6765\u5b89\u88c5\u6700\u65b0\u7248\u672c\u3002<\/p>\n\n\n\n

\"\"<\/figure>\n\n\n\n

1) \u4f7f\u7528 Yum \u5728 CentOS 7 \u4e0a\u5b89\u88c5 MariaDB<\/h2>\n\n\n\n

CentOS \u5b58\u50a8\u5e93\u4e2d MariaDB \u7684\u9ed8\u8ba4\u7248\u672c\u662f MariaDB 5.5\u3002\u867d\u7136\u4e0d\u662f\u6700\u65b0\u7248\u672c\uff0c\u4f46\u5b83\u975e\u5e38\u7a33\u5b9a\uff0c\u5f3a\u70c8\u63a8\u8350\u3002<\/p>\n\n\n\n

\u8981\u5728 CentOS 7 \u4e0a\u5b89\u88c5 MariaDB 5.5\uff0c\u8bf7\u767b\u5f55\u5230\u60a8\u7684\u670d\u52a1\u5668\u5b9e\u4f8b\u5e76\u4f7f\u7528 yum \u5305\u7ba1\u7406\u5668\uff0c\u5982\u56fe\u6240\u793a\u3002<\/p>\n\n\n\n

$ sudo yum install mariadb-server<\/code><\/pre>\n\n\n\n

\u51fa\u73b0\u63d0\u793a\u65f6\uff0c\u6309\u201cy\u201d\u8868\u793a\u201c\u662f\u201d\u4ee5\u7ee7\u7eed\u5b89\u88c5\u8fc7\u7a0b\u3002<\/p>\n\n\n\n

\u8981\u542f\u52a8 MariaDB \u6570\u636e\u5e93\u670d\u52a1\u5668\uff0c\u8bf7\u53d1\u51fa\u547d\u4ee4\uff1a<\/p>\n\n\n\n

$ sudo systemctl start mariadb<\/code><\/pre>\n\n\n\n

\u6b64\u5916\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u542f\u7528 MariaDB \u5728\u542f\u52a8\u65f6\u542f\u52a8\uff1a<\/p>\n\n\n\n

$ sudo systemctl enable mariadb<\/code><\/pre>\n\n\n\n

\u8981\u786e\u8ba4 MariaDB \u662f\u5426\u6b63\u5728\u8fd0\u884c\uff0c\u8bf7\u8fd0\u884c\uff1a<\/p>\n\n\n\n

$ sudo systemctl status  mariadb<\/code><\/pre>\n\n\n\n
\"CentOS
\u68c0\u67e5 mariadb \u72b6\u6001<\/figcaption><\/figure>\n\n\n\n

\u4e0a\u9762\u7684\u8f93\u51fa\u786e\u8ba4 MariaDB \u5df2\u542f\u52a8\u5e76\u6b63\u5728\u8fd0\u884c\u3002\u8981\u786e\u8ba4\u5b89\u88c5\u7684 MariaDB \u7248\u672c\uff0c\u53ea\u9700\u8fd0\u884c\u547d\u4ee4<\/p>\n\n\n\n

mysql -V<\/code><\/pre>\n\n\n\n
\"\u68c0\u67e5
\u68c0\u67e5 MariaDB \u7248\u672c<\/figcaption><\/figure>\n\n\n\n

\u60a8\u8fd8\u53ef\u4ee5\u4f7f\u7528\u6240\u793a\u7684 rpm \u547d\u4ee4\uff1a<\/p>\n\n\n\n

$ rpm -qi | grep mariadb<\/code><\/pre>\n\n\n\n
\"rpm
rpm \u547d\u4ee4\u68c0\u67e5 MariaDB \u7248\u672c<\/figcaption><\/figure>\n\n\n\n

\u60a8\u8fd8\u53ef\u4ee5\u5728\u767b\u5f55\u6570\u636e\u5e93\u65f6\u67e5\u770b MariaDB \u7684\u7248\u672c\u3002<\/p>\n\n\n\n

$ sudo mysql -u root -p<\/code><\/pre>\n\n\n\n
\"\u767b\u5f55
\u767b\u5f55 MariaDB \u670d\u52a1\u5668<\/figcaption><\/figure>\n\n\n\n

2) \u4ece Repo \u5b89\u88c5 MariaDB<\/h2>\n\n\n\n

\u5728\u7f16\u5199\u672c\u6307\u5357\u65f6\uff0cMariaDB \u7684\u6700\u65b0\u7248\u672c\u662f MariaDB 10.4\u3002\u8981\u5b89\u88c5\u5b83\uff0c\u9996\u5148\u521b\u5efa\u4e00\u4e2a\u5b58\u50a8\u5e93\u6587\u4ef6\uff0c\u5982\u4e0b\u6240\u793a\uff1a<\/p>\n\n\n\n

$ sudo vim \/etc\/yum.repos.d\/mariadb.repo<\/code><\/pre>\n\n\n\n

\u63a5\u4e0b\u6765\uff0c\u7c98\u8d34\u4ee5\u4e0b\u5185\u5bb9\uff1a<\/p>\n\n\n\n

[mariadb]\nname = MariaDB baseurl = http:\/\/yum.mariadb.org\/10.4\/centos7-amd64 gpgkey=https:\/\/yum.mariadb.org\/RPM-GPG-KEY-MariaDB gpgcheck=1 <\/code><\/pre>\n\n\n\n

\u4fdd\u5b58\u5e76\u9000\u51fa\u6587\u4ef6\u3002<\/p>\n\n\n\n

\u63a5\u4e0b\u6765\uff0c\u66f4\u65b0 yum \u7f13\u5b58\u7d22\u5f15\uff0c\u5982\u56fe\u6240\u793a\u3002<\/p>\n\n\n\n

$ sudo yum makecache fast<\/code><\/pre>\n\n\n\n

\u8981\u5b89\u88c5 MariaDB 10.4\uff0c\u8bf7\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n\n\n\n

$ sudo yum install mariadb-server mariadb-client<\/code><\/pre>\n\n\n\n

\u51fa\u73b0\u63d0\u793a\u65f6\uff0c\u6309\u201cy\u201d\u8868\u793a\u201c\u662f\u201d\u4ee5\u7ee7\u7eed\u5b89\u88c5\u8fc7\u7a0b\u3002<\/p>\n\n\n\n

\u8981\u542f\u52a8 MariaDB \u6570\u636e\u5e93\u670d\u52a1\u5668\uff0c\u8bf7\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n\n\n\n

$ sudo systemctl start mariadb<\/code><\/pre>\n\n\n\n

\u6b64\u5916\uff0c\u60a8\u53ef\u4ee5\u901a\u8fc7\u8c03\u7528\u4ee5\u4e0b\u547d\u4ee4\u4f7f MariaDB \u5728\u542f\u52a8\u65f6\u542f\u52a8\uff1a<\/p>\n\n\n\n

$ sudo systemctl enable mariadb<\/code><\/pre>\n\n\n\n

\u8981\u786e\u8ba4 MariaDB \u662f\u5426\u6b63\u5728\u8fd0\u884c\uff0c\u8bf7\u8fd0\u884c\uff1a<\/p>\n\n\n\n

$ sudo systemctl status  mariadb<\/code><\/pre>\n\n\n\n

\u540c\u6837\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528\u5404\u79cd\u65b9\u6cd5\u6765\u786e\u8ba4 MariaDB \u7684\u7248\u672c\uff0c\u5982\u524d\u6240\u8ff0\u3002<\/p>\n\n\n\n

$ rpm -qi MariaDB-server<\/code><\/pre>\n\n\n\n
\"CentOS
\u786e\u8ba4\u5b89\u88c5\u4e86\u6700\u65b0\u7684 MariaDB \u670d\u52a1\u5668<\/figcaption><\/figure>\n\n\n\n

\u4ece\u547d\u4ee4\u884c\u8bbf\u95ee MariaDB \u6570\u636e\u5e93<\/h2>\n\n\n\n

\u8981\u4ee5 root \u7528\u6237\u8eab\u4efd\u8bbf\u95ee MariaDB \u6570\u636e\u5e93\uff0c\u8bf7\u8c03\u7528\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n\n\n\n

$ sudo mysql -u root -p<\/code><\/pre>\n\n\n\n

\u7cfb\u7edf\u5c06\u63d0\u793a\u60a8\u8f93\u5165 sudo \u5bc6\u7801\uff0c\u7136\u540e\u662f root \u5bc6\u7801\u3002<\/p>\n\n\n\n

\"\u767b\u5f55<\/figure>\n\n\n\n

\u6b64\u5916\uff0c\u60a8\u53ef\u4ee5\u521b\u5efa\u53e6\u4e00\u4e2a\u7528\u6237\u5e76\u5206\u914d\u6743\u9650\uff0c\u5982\u56fe\u6240\u793a<\/p>\n\n\n\n

MariaDB [(none)] >  create user 'linoxide'@'localhost' IDENTIFIED BY  'Password';\nMariaDB [(none)] > GRANT ALL PRIVILEGES ON *.* TO 'linoxide'@'localhost';<\/code><\/pre>\n\n\n\n

\u63a5\u4e0b\u6765\uff0c\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u6ce8\u9500\uff1a<\/p>\n\n\n\n

MariaDB [(none)] > quit;<\/code><\/pre>\n\n\n\n

\u7136\u540e\u4f7f\u7528\u7528\u6237\u767b\u5f55<\/p>\n\n\n\n

$ sudo mysql -u linoxide  -p<\/code><\/pre>\n\n\n\n

\u4ece CentOS 7 \u4e2d\u5220\u9664 MariaDB<\/h2>\n\n\n\n

\u5982\u679c\u60a8\u5e0c\u671b\u4ece CentOs 7 \u4e2d\u5220\u9664\u60a8\u7684 MariaDB \u5b9e\u4f8b\uff0c\u8bf7\u5148\u505c\u6b62 MariaDB \u670d\u52a1\u3002<\/p>\n\n\n\n

$ sudo systemctl stop mariadb.service<\/code><\/pre>\n\n\n\n

\u63a5\u4e0b\u6765\uff0c\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u4ece CentOS 7 \u4e2d\u5b8c\u5168\u5220\u9664 MariaDB\uff1a<\/p>\n\n\n\n

$ sudo yum remove -y mariadb-server mariadb-client<\/code><\/pre>\n\n\n\n

\u6700\u540e\uff0c\u5220\u9664\u6240\u6709\u6570\u636e\u6587\u4ef6\uff0c\u5982\u56fe\u6240\u793a\u3002<\/p>\n\n\n\n

$ sudo rm -rf \/var\/lib\/mysql  \/etc\/my.cnf<\/code><\/pre>\n\n\n\n

\u76f8\u5173\u9605\u8bfb\uff1a<\/p>\n\n\n\n