{"id":868,"date":"2022-03-18T21:56:44","date_gmt":"2022-03-18T13:56:44","guid":{"rendered":"https:\/\/www.buyao007.icu\/?p=868"},"modified":"2022-03-18T21:58:01","modified_gmt":"2022-03-18T13:58:01","slug":"1-mysql%e4%ba%8c%e8%bf%9b%e5%88%b6%e5%ae%89%e8%a3%85","status":"publish","type":"post","link":"https:\/\/www.buyao007.icu\/?p=868","title":{"rendered":"1.Mysql\u4e8c\u8fdb\u5236\u5b89\u88c5"},"content":{"rendered":"\n<p>\u5b59\u5bcc\u9633\uff0c \u6c5f\u6e56\u4eba\u79f0\u6ca1\u4eba\u79f0\u3002\u591a\u5e74\u4e92\u8054\u7f51\u8fd0\u7ef4\u5de5\u4f5c\u7ecf\u9a8c\uff0c\u66fe\u8d1f\u8d23\u8fc7\u5b59\u5e03\u65af\u5927\u89c4\u6a21\u96c6\u7fa4\u67b6\u6784\u81ea\u52a8\u5316\u8fd0\u7ef4\u7ba1\u7406\u5de5\u4f5c\u3002\u64c5\u957fWeb\u96c6\u7fa4\u67b6\u6784\u4e0e\u81ea\u52a8\u5316\u8fd0\u7ef4\uff0c\u66fe\u8d1f\u8d23\u56fd\u5185\u67d0\u5927\u578b\u535a\u5ba2\u7f51\u7ad9\u8fd0\u7ef4\u5de5\u4f5c\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"toc_0\">1.\u4e0b\u8f7d\u4e8c\u8fdb\u5236\u5305\u5e76\u4e0a\u4f20\u81f3\u670d\u52a1\u5668<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>\u4e8c\u8fdb\u5236\u5305\u4e0b\u8f7d\u5730\u5740\uff1a\nhttps:&#47;&#47;downloads.mysql.com\/archives\/community\/\n\n&#91;root@db01 \/opt]# wget https:\/\/downloads.mysql.com\/archives\/get\/p\/23\/file\/mysql-8.0.20-linux-glibc2.12-x86_64.tar.xz\n#\u89e3\u538b\n&#91;root@db01 \/opt]# tar xf mysql-8.0.20-linux-glibc2.12-x86_64.tar.xz\n#\u521b\u5efa\u8f6f\u8fde\u63a5\n&#91;root@db01 \/opt]# ln -s \/opt\/mysql-8.0.20-linux-glibc2.12-x86_64 \/usr\/local\/mysql\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"toc_0\">2.\u57fa\u7840\u73af\u5883\u51c6\u5907<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>##Linux\u53ef\u80fd\u5b89\u88c5\u4e86mariadb-libs\uff0c\u9700\u8981\u79fb\u9664mariadb\n&#91;root@db01 \/opt]# yum remove mariadb-libs.x86_64 -y\n#\u521b\u5efa\u7528\u6237\n&#91;root@db01 \/opt]# groupadd -g 27 mysql\n&#91;root@db01 \/opt]# useradd -u 27 -g 27 -M -s \/sbin\/nologin mysql\n#\u521b\u5efa\u6570\u636e\u76ee\u5f55\u5e76\u6388\u6743\n&#91;root@db01 \/opt]# mkdir -p \/data\/3306\/data\n&#91;root@db01 \/opt]# chown -R mysql. \/data\n#\u8bbe\u7f6e\u73af\u5883\u53d8\u91cf\nexport PATH=\/usr\/local\/mysql\/bin:$PATH\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"toc_0\">3.\u521d\u59cb\u5316\u6570\u636e\u5e93<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;root@db01 \/opt]# mysqld --initialize-insecure --user=mysql --basedir=\/usr\/local\/mysql --datadir=\/data\/3306\/data\n##\u6709\u53ef\u80fd\u7684\u62a5\u9519\nlibaio\u95ee\u9898--> yum -y install libaio-devel\n--initialize specified but the data directory has files in it. Aborting-->\u6570\u636e\u76ee\u5f55\u91cc\u6709\u6587\u4ef6\uff0c\u9700\u8981\u5220\u9664\u540e\u91cd\u65b0\u521d\u59cb\u5316\uff0c\u6216\u8005\u5efa\u4e00\u4e2a\u7a7a\u76ee\u5f55\u91cd\u65b0\u521d\u59cb\u5316\n#\u521d\u59cb\u5316\u53c2\u6570\u8bf4\u660e\n--initialize-insecure   \u521d\u59cb\u5316\u7684\u6838\u5fc3\u53c2\u6570\n--user=mysql   \u6307\u5b9a\u521d\u59cb\u5316\u7528\u6237\n--basedir=\/usr\/local\/mysql   \u6570\u636e\u5e93\u8f6f\u4ef6\u4f4d\u7f6e\n--datadir=\/data\/3306\/data   \u6570\u636e\u5e93\u6570\u636e\u76ee\u5f55\n<strong>5.7\u548c8.0\u7684\u521d\u59cb\u5316\u547d\u4ee4\u662f\u4e00\u6837\u7684<\/strong>\n<strong>5.7\u4e4b\u524d\u7248\u672c\u7684\u521d\u59cb\u5316\u547d\u4ee4<\/strong>\n\/usr\/local\/mysql\/scripts\/mysql_install_db --user=mysql --basedir=\/usr\/local\/mysql --datadir=\/data\/3306\/data\n5.7\u548c8.0\u63d0\u4f9b\u4e86\u4e24\u4e2a\u6838\u5fc3\u521d\u59cb\u5316\u53c2\u6570--initialize\u548c--initialize-insecure\n--initialize \u4f1a\u751f\u6210\u4e34\u65f6\u5bc6\u7801\uff0c4\u79cd\u5bc6\u7801\u590d\u6742\u5bc6\u7801\uff0c\u767b\u5f55\u5b8c\u6210\u8981\u6539\u6389\u5bc6\u7801\n--initialize-insecure \u7ba1\u7406\u5458\u5bc6\u7801\u4e3a\u7a7a\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"toc_0\">4.\u521b\u5efa\u914d\u7f6e\u6587\u4ef6<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;root@db01 \/opt]# cat \/etc\/my.cnf \n&#91;mysqld]\nuser=mysql\nbasedir=\/usr\/local\/mysql\ndatadir=\/data\/3306\/data\nport=3306\nsocket=\/tmp\/mysql.sock\n&#91;client]\nsocket=\/tmp\/mysql.sock\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"toc_0\">5.\u914d\u7f6esystemd\u7ba1\u7406mysql<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;root@db01 \/opt]# cd \/usr\/local\/mysql\/support-files\/\n&#91;root@db01 \/usr\/local\/mysql\/support-files]# cp .\/mysql.server \/etc\/init.d\/mysql\n&#91;root@db01 \/usr\/local\/mysql\/support-files]# systemctl enable mysql\n<\/code><\/pre>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5b59\u5bcc\u9633\uff0c \u6c5f\u6e56\u4eba\u79f0\u6ca1\u4eba\u79f0\u3002\u591a\u5e74\u4e92\u8054\u7f51\u8fd0\u7ef4\u5de5\u4f5c\u7ecf\u9a8c\uff0c\u66fe\u8d1f\u8d23\u8fc7\u5b59\u5e03\u65af\u5927\u89c4\u6a21\u96c6\u7fa4\u67b6\u6784\u81ea\u52a8\u5316\u8fd0\u7ef4\u7ba1\u7406\u5de5\u4f5c\u3002\u64c5\u957fWeb\u96c6 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[29],"tags":[],"_links":{"self":[{"href":"https:\/\/www.buyao007.icu\/index.php?rest_route=\/wp\/v2\/posts\/868"}],"collection":[{"href":"https:\/\/www.buyao007.icu\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.buyao007.icu\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.buyao007.icu\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.buyao007.icu\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=868"}],"version-history":[{"count":3,"href":"https:\/\/www.buyao007.icu\/index.php?rest_route=\/wp\/v2\/posts\/868\/revisions"}],"predecessor-version":[{"id":872,"href":"https:\/\/www.buyao007.icu\/index.php?rest_route=\/wp\/v2\/posts\/868\/revisions\/872"}],"wp:attachment":[{"href":"https:\/\/www.buyao007.icu\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=868"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.buyao007.icu\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=868"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.buyao007.icu\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=868"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}