{"id":112,"date":"2024-06-14T09:24:40","date_gmt":"2024-06-14T01:24:40","guid":{"rendered":"http:\/\/zhaoyanqi.cn\/?p=112"},"modified":"2024-06-19T22:15:17","modified_gmt":"2024-06-19T14:15:17","slug":"centos-7-9%e4%b8%8a%e9%80%9a%e8%bf%87%e6%ba%90%e7%a0%81%e5%ae%89%e8%a3%85mysql%ef%bc%8c%e5%b9%b6%e7%bb%9f%e4%b8%80%e5%ad%97%e7%ac%a6%e7%bc%96%e7%a0%81%e4%bb%a5%e5%8f%8a%e9%85%8d%e7%bd%ae%e4%b8%ba","status":"publish","type":"post","link":"https:\/\/zhaoyanqi.cn\/?p=112","title":{"rendered":"CentOS 7.9\u4e0a\u901a\u8fc7\u6e90\u7801\u5b89\u88c5MySQL\uff0c\u5e76\u7edf\u4e00\u5b57\u7b26\u7f16\u7801\u4ee5\u53ca\u914d\u7f6e\u4e3a\u7cfb\u7edf\u670d\u52a1"},"content":{"rendered":"\n<h3 class=\"wp-block-heading\" id=\"712db96e\">1. \u5b89\u88c5\u5fc5\u8981\u7684\u4f9d\u8d56\u5305<\/h3>\n\n\n\n<p id=\"ud193d52b\">\u9996\u5148\uff0c\u786e\u4fdd\u7cfb\u7edf\u5df2\u5b89\u88c5\u6784\u5efaMySQL\u6240\u9700\u7684\u4f9d\u8d56\u5305\uff1a<\/p>\n\n\n\n<pre id=\"9817473c\" class=\"wp-block-code\"><code>sudo yum install centos-release-scl#\u542f\u7528SCL\uff08Software Collections\uff09\u4ed3\u5e93\nsudo yum update -y\nsudo yum groupinstall -y \"Development Tools\"\nsudo yum install -y cmake3 ncurses-devel openssl-devel libaio-devel bison wget\nsudo yum install devtoolset-11-gcc devtoolset-11-gcc-c++ devtoolset-11-binutils #\u5b89\u88c5Devtoolset-11\nscl enable devtoolset-11 bash #\u6bcf\u6b21\u4f7f\u7528\u65f6\u90fd\u9700\u8981\u542f\u7528Devtoolset-11\necho \"source \/opt\/rh\/devtoolset-11\/enable\" &gt;&gt; ~\/.bashrc #\u4e3a\u4e86\u65b9\u4fbf\uff0c\u53ef\u4ee5\u5c06\u5176\u6dfb\u52a0\u5230shell\u542f\u52a8\u811a\u672c\u4e2d\uff0c\u4f8b\u5982~\/.bashrc\nsource ~\/.bashrc<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"0b184769\">2. \u4e0b\u8f7dMySQL\u6e90\u7801<\/h3>\n\n\n\n<p id=\"u82f9b56a\">\u4eceMySQL\u5b98\u65b9\u7f51\u7ad9\u4e0b\u8f7d\u6700\u65b0\u7684MySQL\u6e90\u7801\u5305\uff1a<\/p>\n\n\n\n<pre id=\"d98bc6c2\" class=\"wp-block-code\"><code>wget https:\/\/dev.mysql.com\/get\/Downloads\/MySQL-8.0\/mysql-8.0.30.tar.gz\ntar -zxvf mysql-8.0.30.tar.gz\ncd mysql-8.0.30<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"70955c8b\">3. \u7f16\u8bd1\u548c\u5b89\u88c5MySQL<\/h3>\n\n\n\n<p id=\"uda0f6b7e\">\u521b\u5efa\u6784\u5efa\u76ee\u5f55\u5e76\u914d\u7f6eMySQL\uff1a<\/p>\n\n\n\n<pre id=\"e2df7ff6\" class=\"wp-block-code\"><code>mkdir build\ncd build\ncmake3 .. -DDOWNLOAD_BOOST=1 -DWITH_BOOST=..\/boost\nmake\nsudo make install<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"b70a5f04\">4. \u521d\u59cb\u5316\u6570\u636e\u5e93<\/h3>\n\n\n\n<p id=\"u78a0be19\">\u521b\u5efaMySQL\u7684\u7528\u6237\u548c\u7ec4\uff1a<\/p>\n\n\n\n<pre id=\"78262061\" class=\"wp-block-code\"><code>sudo groupadd mysql\nsudo useradd -r -g mysql -s \/bin\/false mysql<\/code><\/pre>\n\n\n\n<p id=\"u41e55b10\">\u521d\u59cb\u5316MySQL\u6570\u636e\u76ee\u5f55\uff1a<\/p>\n\n\n\n<pre id=\"397a23e9\" class=\"wp-block-code\"><code>sudo mkdir -p \/usr\/local\/mysql\/data\nsudo chown -R mysql:mysql \/usr\/local\/mysql\nsudo chmod 750 \/usr\/local\/mysql\/data\nsudo \/usr\/local\/mysql\/bin\/mysqld --initialize --user=mysql --datadir=\/usr\/local\/mysql\/data<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"9da09d6a\">5. \u914d\u7f6e\u5b57\u7b26\u7f16\u7801<\/h3>\n\n\n\n<p id=\"u218d744c\">\u7f16\u8f91MySQL\u7684\u914d\u7f6e\u6587\u4ef6<code>my.cnf<\/code>\uff0c\u786e\u4fdd\u5b57\u7b26\u7f16\u7801\u4e3aUTF-8\uff1a<\/p>\n\n\n\n<pre id=\"a3e86ff7\" class=\"wp-block-code\"><code>sudo vi \/etc\/my.cnf<\/code><\/pre>\n\n\n\n<p id=\"u2c1eef2e\">\u6dfb\u52a0\u4ee5\u4e0b\u5185\u5bb9\uff1a<\/p>\n\n\n\n<pre id=\"de5f49fc\" class=\"wp-block-code\"><code>&#91;mysqld]\nbasedir=\/usr\/local\/mysql\ndatadir=\/usr\/local\/mysql\/data\nsocket=\/var\/lib\/mysql\/mysql.sock\nuser=mysql\nsymbolic-links=0\n\ncharacter-set-server=utf8mb4\ncollation-server=utf8mb4_unicode_ci\n\n&#91;client]\nsocket=\/var\/lib\/mysql\/mysql.sock\n\n&#91;mysql]\nsocket=\/var\/lib\/mysql\/mysql.sock<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"d59511d4\">6. \u914d\u7f6eMySQL\u4e3a\u7cfb\u7edf\u670d\u52a1<\/h3>\n\n\n\n<p id=\"u2e7b5fe1\">\u521b\u5efaMySQL\u7684systemd\u670d\u52a1\u6587\u4ef6\uff1a<\/p>\n\n\n\n<pre id=\"44d51414\" class=\"wp-block-code\"><code>sudo vi \/etc\/systemd\/system\/mysql.service<\/code><\/pre>\n\n\n\n<p id=\"u7a048157\">\u6dfb\u52a0\u4ee5\u4e0b\u5185\u5bb9\uff1a<\/p>\n\n\n\n<pre id=\"4c767e5c\" class=\"wp-block-code\"><code>&#91;Unit]\nDescription=MySQL Server\nAfter=network.target\n\n&#91;Service]\nUser=mysql\nGroup=mysql\nExecStart=\/usr\/local\/mysql\/bin\/mysqld --defaults-file=\/etc\/my.cnf\nLimitNOFILE=5000\n\n&#91;Install]\nWantedBy=multi-user.target<\/code><\/pre>\n\n\n\n<p id=\"u038d21c8\">\u91cd\u65b0\u52a0\u8f7dsystemd\u914d\u7f6e\uff0c\u542f\u52a8\u5e76\u542f\u7528MySQL\u670d\u52a1\uff1a<\/p>\n\n\n\n<pre id=\"e78cf8c8\" class=\"wp-block-code\"><code>sudo systemctl daemon-reload\nsudo systemctl start mysql\nsudo systemctl enable mysql<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"298da7ae\">7. \u8bbe\u7f6eMySQL root\u7528\u6237\u5bc6\u7801<\/h3>\n\n\n\n<p id=\"u893deb0b\">\u4f7f\u7528\u4e34\u65f6\u751f\u6210\u7684\u5bc6\u7801\u767b\u5f55\u5e76\u4fee\u6539root\u7528\u6237\u5bc6\u7801\uff1a<\/p>\n\n\n\n<pre id=\"baf9f426\" class=\"wp-block-code\"><code>sudo \/usr\/local\/mysql\/bin\/mysql_secure_installation<\/code><\/pre>\n\n\n\n<p id=\"u60b7003b\">\u6309\u7167\u63d0\u793a\u8fdb\u884c\u64cd\u4f5c\uff0c\u8bbe\u7f6eroot\u7528\u6237\u7684\u65b0\u5bc6\u7801\uff0c\u5e76\u5b8c\u6210\u5b89\u5168\u6027\u8bbe\u7f6e\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"7709cb04\">8. \u9a8c\u8bc1\u5b57\u7b26\u7f16\u7801<\/h3>\n\n\n\n<p id=\"u04c96b5d\">\u767b\u5f55MySQL\u5e76\u9a8c\u8bc1\u5b57\u7b26\u7f16\u7801\u8bbe\u7f6e\u662f\u5426\u6b63\u786e\uff1a<\/p>\n\n\n\n<pre id=\"d2a675df\" class=\"wp-block-code\"><code>\/usr\/local\/mysql\/bin\/mysql -u root -p<\/code><\/pre>\n\n\n\n<p id=\"u0d21a59e\">\u8fd0\u884c\u4ee5\u4e0bSQL\u547d\u4ee4\uff1a<\/p>\n\n\n\n<pre id=\"9b518a56\" class=\"wp-block-code\"><code>SHOW VARIABLES LIKE 'character_set%';\nSHOW VARIABLES LIKE 'collation%';<\/code><\/pre>\n\n\n\n<p id=\"u980a2bb1\">\u786e\u4fdd\u8f93\u51fa\u7ed3\u679c\u663e\u793a<code>utf8mb4<\/code>\u548c<code>utf8mb4_unicode_ci<\/code>\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><div class='fancybox-wrapper lazyload-container-unload' data-fancybox='post-images' href='https:\/\/zhaoyanqi.cn\/wp-content\/uploads\/2024\/06\/image.png'><img class=\"lazyload lazyload-style-1\" src=\"data:image\/svg+xml;base64,PCEtLUFyZ29uTG9hZGluZy0tPgo8c3ZnIHdpZHRoPSIxIiBoZWlnaHQ9IjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgc3Ryb2tlPSIjZmZmZmZmMDAiPjxnPjwvZz4KPC9zdmc+\"  loading=\"lazy\" decoding=\"async\" width=\"902\" height=\"750\" data-original=\"https:\/\/zhaoyanqi.cn\/wp-content\/uploads\/2024\/06\/image.png\" src=\"data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB\/AAffA0nNPuCLAAAAAElFTkSuQmCC\" alt=\"\" class=\"wp-image-114\" style=\"width:611px;height:auto\"  sizes=\"auto, (max-width: 902px) 100vw, 902px\" \/><\/div><\/figure>\n\n\n\n<p id=\"udc1e3a5f\"><\/p>\n","protected":false},"excerpt":{"rendered":"<p>1. \u5b89\u88c5\u5fc5\u8981\u7684\u4f9d\u8d56\u5305 \u9996\u5148\uff0c\u786e\u4fdd\u7cfb\u7edf\u5df2\u5b89\u88c5\u6784\u5efaMySQL\u6240\u9700\u7684\u4f9d\u8d56\u5305\uff1a 2. \u4e0b\u8f7dMySQL\u6e90\u7801 \u4eceMySQ [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8,15],"tags":[10],"class_list":["post-112","post","type-post","status-publish","format-standard","hentry","category-mysql","category-mysql_deploy","tag-mysql_lab"],"_links":{"self":[{"href":"https:\/\/zhaoyanqi.cn\/index.php?rest_route=\/wp\/v2\/posts\/112","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/zhaoyanqi.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/zhaoyanqi.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/zhaoyanqi.cn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/zhaoyanqi.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=112"}],"version-history":[{"count":2,"href":"https:\/\/zhaoyanqi.cn\/index.php?rest_route=\/wp\/v2\/posts\/112\/revisions"}],"predecessor-version":[{"id":117,"href":"https:\/\/zhaoyanqi.cn\/index.php?rest_route=\/wp\/v2\/posts\/112\/revisions\/117"}],"wp:attachment":[{"href":"https:\/\/zhaoyanqi.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=112"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/zhaoyanqi.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=112"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/zhaoyanqi.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=112"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}