{"id":962,"date":"2024-11-15T14:07:10","date_gmt":"2024-11-15T06:07:10","guid":{"rendered":"http:\/\/www.huerpu.cc:7000\/?p=962"},"modified":"2024-11-18T16:21:45","modified_gmt":"2024-11-18T08:21:45","slug":"ubuntu24-04%e4%b8%8a%e5%ae%89%e8%a3%85%e5%92%8c%e9%85%8d%e7%bd%aemysql8-4-3","status":"publish","type":"post","link":"http:\/\/www.huerpu.cc:7000\/?p=962","title":{"rendered":"Ubuntu24.04\u4e0a\u5b89\u88c5\u548c\u914d\u7f6eMySQL8.4.3"},"content":{"rendered":"<h1>Ubuntu24.04\u4e0a\u5b89\u88c5\u548c\u914d\u7f6eMySQL8.4.3<\/h1>\n<h2>\u4e00\u3001\u914d\u7f6eMySQL<\/h2>\n<pre><code class=\"language-shell\">#MySQL \u7684 APT \u914d\u7f6e\u5de5\u5177\u5305:https:\/\/repo.mysql.com\/\uff0c\u6700\u65b0\u7248\u7684\u5c31\u662f\u8fd9\u4e2a\u4e86\nwget https:\/\/repo.mysql.com\/mysql-apt-config_0.8.33-1_all.deb\n\n#\u8f93\u5165\u8fd9\u6761\u547d\u4ee4\uff0c\u9009\u62e9MySQL8.4\u957f\u671f\u652f\u6301\u8fd9\u4e2a\u7248\u672c\uff0c\u7b2c\u4e8c\u4e2a\u9009\u62e9Enable\uff0c\u7136\u540e\u9009\u62e9OK\nsudo dpkg -i mysql-apt-config_0.8.33-1_all.deb<\/code><\/pre>\n<p><img decoding=\"async\" src=\"\/wp-content\/uploads\/2024\/11\/18\/Screenshot-2024-11-18-152911.png\" alt=\"Screenshot 2024-11-18 152911\" \/><\/p>\n<h2>\u4e8c\u3001\u5b89\u88c5MySQL<\/h2>\n<pre><code class=\"language-shell\">#\u66f4\u65b0\u6e90\napt update \napt upgrade -y\n\n#\u5b89\u88c5\napt -y install mysql-server\n\n#\u67e5\u770b\u72b6\u6001\nsystemctl status mysql<\/code><\/pre>\n<h2>\u4e09\u3001\u8bbe\u7f6eroot\u7528\u6237\u8fdc\u7a0b\u8bbf\u95ee<\/h2>\n<pre><code class=\"language-shell\">#\u767b\u5f55MySQL\nmysql -uroot -p\n\n#\u8bbe\u7f6eroot\u7528\u6237\u53ef\u4ee5\u8fdc\u7a0b\u767b\u5f55\nupdate mysql.user set host = &#039;%&#039; where user=&#039;root&#039;;\nFLUSH PRIVILEGES;\nALTER USER &#039;root&#039;@&#039;%&#039; IDENTIFIED BY &#039;\u65b0\u5bc6\u7801&#039;;\nGRANT ALL PRIVILEGES ON *.* TO &#039;root&#039;@&#039;%&#039; WITH GRANT OPTION;\nFLUSH PRIVILEGES;\n\n#\u53bb\u6389bind 127.0.0.1\nvim \/etc\/mysql\/mysql.conf.d\/mysqld.cnf\n#\u628a\u8fd9\u4e24\u884c\u6ce8\u91ca\u6389\nbind = 127.0.0.1\nmysqlx-bind-address     = 127.0.0.1<\/code><\/pre>\n<h2>\u56db\u3001\u521b\u5efa\u7528\u6237\u5e76\u8d4b\u4e88\u6743\u9650<\/h2>\n<pre><code class=\"language-shell\">#\u521b\u5efa\u4e00\u4e2amyuser\u7684\u7528\u6237\uff0c\u5e76\u8d4b\u4e88root\u6240\u6709\u6743\u9650\nCREATE USER &#039;myuser&#039;@&#039;%&#039; IDENTIFIED BY &#039;admin123&#039;;\nGRANT ALL PRIVILEGES ON *.* TO &#039;myuser&#039;@&#039;%&#039; WITH GRANT OPTION;\nFLUSH PRIVILEGES;\nquit;<\/code><\/pre>\n<h2>\u4e94\u3001MySQL\u7684\u76f8\u5173\u64cd\u4f5c<\/h2>\n<pre><code class=\"language-shell\">#\u767b\u5f55MySQL\nmysql -uroot -p\n\n#\u53ef\u9009\u9879\uff0c\u914d\u7f6emysql\u5b89\u5168\u8bbf\u95ee\u7684\u8bbe\u7f6e\nsudo mysql_secure_installation\n######\u5728\u8be5\u8fc7\u7a0b\u4e2d\uff0c\u4f60\u4f1a\u88ab\u63d0\u793a\u4e00\u4e9b\u95ee\u9898\u3002\u4e0b\u9762\u662f\u4e00\u4e9b\u63a8\u8350\u7684\u914d\u7f6e\uff1a\n#####Validate Password Plugin: \u4f60\u53ef\u4ee5\u9009\u62e9\u662f\u5426\u542f\u7528 MySQL \u7684\u5bc6\u7801\u5f3a\u5ea6\u9a8c\u8bc1\u63d2\u4ef6\u3002\u5982\u679c\u9009\u62e9\u542f\u7528\uff0c\u5b83\u4f1a\u8981\u6c42\u8bbe\u7f6e\u5f3a\u5bc6\u7801\u3002\u5982\u679c\u662f\u5f00\u53d1\u73af\u5883\uff0c\u4f60\u53ef\u4ee5\u9009\u62e9\u4e0d\u542f\u7528\u3002\n####Remove Anonymous Users: \u5efa\u8bae\u79fb\u9664\u533f\u540d\u7528\u6237\uff0c\u4fdd\u8bc1\u5b89\u5168\u6027\u3002\n###Disallow Root Login Remotely: \u5982\u679c\u4f60\u4e0d\u9700\u8981\u4ece\u8fdc\u7a0b\u767b\u5f55 root \u7528\u6237\uff0c\u5efa\u8bae\u7981\u6b62 root \u7528\u6237\u7684\u8fdc\u7a0b\u767b\u5f55\u3002\n##Remove Test Database: \u5efa\u8bae\u5220\u9664\u6d4b\u8bd5\u6570\u636e\u5e93\u548c\u76f8\u5e94\u7684\u8bbf\u95ee\u6743\u9650\u3002\n#Reload Privilege Tables Now: \u6700\u540e\u9009\u62e9\u91cd\u65b0\u52a0\u8f7d\u6743\u9650\u8868\uff0c\u4f7f\u5f97\u4fee\u6539\u751f\u6548\u3002\n\n#\u67e5\u770bmysql\u7248\u672c\nSELECT VERSION();\n\n#\u91cd\u542fmysql\nsystemctl restart mysql\n\n#\u8fd0\u884cMySQL\nsystemctl start mysql\n\n#\u67e5\u770bMySQL\u72b6\u6001\nsystemctl status mysql\n\n#\u5f00\u653e3306\u7aef\u53e3\nufw allow 3306\nufw enable\n\n#\u67e5\u770bMysql 3306\u7aef\u53e3\nnetstat -tlnp | grep 3306<\/code><\/pre>\n<blockquote>\n<p>Reference:<\/p>\n<p>\u5982\u4f55\u5728Ubuntu24.04\u4e0a\u5b89\u88c5\u548c\u914d\u7f6eMySQL:<a href=\"https:\/\/www.jianshu.com\/p\/63653874b27e\">https:\/\/www.jianshu.com\/p\/63653874b27e<\/a><\/p>\n<p>MySQL \u7684 APT \u914d\u7f6e\u5de5\u5177\u5305:<a href=\"https:\/\/repo.mysql.com\/\">https:\/\/repo.mysql.com\/<\/a><\/p>\n<\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>Ubuntu24.04\u4e0a\u5b89\u88c5\u548c\u914d\u7f6eMySQL8.4.3 \u4e00\u3001\u914d\u7f6eMySQL #MySQL \u7684 APT \u914d\u7f6e\u5de5\u5177 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[30],"tags":[],"class_list":["post-962","post","type-post","status-publish","format-standard","hentry","category-ubuntu"],"_links":{"self":[{"href":"http:\/\/www.huerpu.cc:7000\/index.php?rest_route=\/wp\/v2\/posts\/962","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.huerpu.cc:7000\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.huerpu.cc:7000\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.huerpu.cc:7000\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.huerpu.cc:7000\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=962"}],"version-history":[{"count":5,"href":"http:\/\/www.huerpu.cc:7000\/index.php?rest_route=\/wp\/v2\/posts\/962\/revisions"}],"predecessor-version":[{"id":975,"href":"http:\/\/www.huerpu.cc:7000\/index.php?rest_route=\/wp\/v2\/posts\/962\/revisions\/975"}],"wp:attachment":[{"href":"http:\/\/www.huerpu.cc:7000\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=962"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.huerpu.cc:7000\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=962"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.huerpu.cc:7000\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=962"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}