{"id":1191,"date":"2024-08-27T06:53:45","date_gmt":"2024-08-26T22:53:45","guid":{"rendered":"https:\/\/blog.axqd.net\/?p=1191"},"modified":"2024-08-27T07:03:35","modified_gmt":"2024-08-26T23:03:35","slug":"mysql%e5%8d%87%e7%ba%a7%e5%90%8e%e4%bb%8emysql_native_password%e8%ae%a4%e8%af%81%e6%a8%a1%e5%9d%97%e6%9b%b4%e6%94%b9%e4%b8%bacaching_sha2_password","status":"publish","type":"post","link":"https:\/\/blog.axqd.net\/?p=1191","title":{"rendered":"MySQL\u5347\u7ea7\u540e\u4ecemysql_native_password\u8ba4\u8bc1\u6a21\u5757\u66f4\u6539\u4e3acaching_sha2_password"},"content":{"rendered":"\n<p>MySQL 8.4 LTS \u5f00\u59cb\u9ed8\u8ba4\u4f7f\u7528<code>caching_sha2_password<\/code>\u8ba4\u8bc1\u63d2\u4ef6\uff0c\u6765\u53d6\u4ee3\u4e0d\u592a\u5b89\u5168\u7684<code>mysql_native_password<\/code>\u8ba4\u8bc1\u63d2\u4ef6\u3002\u7f51\u4e0a\u5f88\u591a\u7684\u6587\u7ae0\u89e3\u51b3\u8fd9\u4e2a\u95ee\u9898\u7684\u65b9\u6cd5\uff0c\u662f\u542f\u52a8MySQL\u7684\u65f6\u5019\uff0c\u52a0\u4e0a<code>--mysql-native-password=ON<\/code>\u9009\u9879\uff0c\u4ee5\u56de\u9000\u5e76\u7ee7\u7eed\u4f7f\u7528<code>mysql_native_password<\/code>\u8ba4\u8bc1\u63d2\u4ef6\u3002\u7136\u800c\uff0c\u5728MySQL 9.0\u4ee5\u540e\uff0c<code>mysql_native_password<\/code>\u8ba4\u8bc1\u63d2\u4ef6\u4e0d\u518d\u88ab\u652f\u6301\u3002\u6240\u4ee5\u66f4\u597d\u7684\u89e3\u51b3\u529e\u6cd5\uff0c\u8fd8\u662f\u5f7b\u5e95\u66f4\u6539\u8ba4\u8bc1\u65b9\u5f0f\u4e3a<code>caching_sha2_password<\/code>\u3002<\/p>\n\n\n\n<p>\u9996\u5148\u5347\u7ea7MySQL\u52308.4+\u540e\u6b63\u5e38\u542f\u52a8\uff0c\u9ed8\u8ba4\u8ba4\u8bc1\u6a21\u5757\u4f1a\u53d8\u66f4\u4e3a<code>caching_sha2_password<\/code>\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>DROP USER 'foo'@'%';\nCREATE USER 'foo'@'%' IDENTIFIED BY 'password';\nGRANT ALL PRIVILEGES ON BAR.* TO 'foo'@'%';\nFLUSH PRIVILEGES;<\/code><\/pre>\n\n\n\n<p>\u6ce8\u610f\uff1a<br>1. \u53ea\u662f <code>DELETE FROM mysql.user where User=\"foo\"; FLUSH PRIVILEGES;<\/code> \u53ef\u80fd\u4f1a\u5bfc\u81f4<code>CREATE USER<\/code>\u5931\u8d25\uff0c\u9700\u8981\u5148<code>DROP USER<\/code>\u3002<br>2. \u5982\u679c\u5347\u7ea7\u540e\u65e0\u6cd5\u767b\u9646\uff0c\u53ef\u4ee5\u542f\u52a8MySQL\u7684\u65f6\u5019\u52a0\u4e0a<code>--skip-grant-tables<\/code>\u4ee5\u4e34\u65f6\u8df3\u8fc7\u8ba4\u8bc1\u3002<br>3. \u5bf9\u4e8e<code>root<\/code>\u7528\u6237\uff0c\u53ef\u4ee5\u52a0\u4e0a<code>WITH GRANT OPTION<\/code><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION;<\/code><\/pre>\n\n\n\n<p>\u5ba2\u6237\u7aef\u8fd9\u8fb9\uff0c\u4ee5PHP\u4e3a\u4f8b\uff0c\u9700\u8981\u786e\u8ba4\u652f\u6301<code>caching_sha2_password<\/code>\u8ba4\u8bc1\u63d2\u4ef6\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;?php\nphpinfo();\n?&gt;<\/code><\/pre>\n\n\n\n<p>\u4f1a\u663e\u793a\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>mysqlnd - Loaded plugins:\nauth_plugin_caching_sha2_password<\/code><\/pre>\n\n\n\n<p>\u5982\u679c\u4e0d\u652f\u6301\uff0c\u8bf7\u5347\u7ea7\u7248\u672c\u3002<\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>MySQL 8.4 LTS \u5f00\u59cb\u9ed8\u8ba4\u4f7f\u7528caching_sha2_password\u8ba4\u8bc1\u63d2\u4ef6\uff0c\u6765\u53d6\u4ee3\u4e0d\u592a\u5b89\u5168\u7684m &hellip; <a href=\"https:\/\/blog.axqd.net\/?p=1191\" class=\"more-link\">\u7ee7\u7eed\u9605\u8bfb<span class=\"screen-reader-text\">\u201cMySQL\u5347\u7ea7\u540e\u4ecemysql_native_password\u8ba4\u8bc1\u6a21\u5757\u66f4\u6539\u4e3acaching_sha2_password\u201d<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[228],"tags":[227,118,163],"class_list":["post-1191","post","type-post","status-publish","format-standard","hentry","category-228","tag-mysql","tag-php","tag-wordpress"],"_links":{"self":[{"href":"https:\/\/blog.axqd.net\/index.php?rest_route=\/wp\/v2\/posts\/1191","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.axqd.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.axqd.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.axqd.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.axqd.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1191"}],"version-history":[{"count":2,"href":"https:\/\/blog.axqd.net\/index.php?rest_route=\/wp\/v2\/posts\/1191\/revisions"}],"predecessor-version":[{"id":1194,"href":"https:\/\/blog.axqd.net\/index.php?rest_route=\/wp\/v2\/posts\/1191\/revisions\/1194"}],"wp:attachment":[{"href":"https:\/\/blog.axqd.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1191"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.axqd.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1191"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.axqd.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1191"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}