{"id":9039,"date":"2026-11-06T14:01:20","date_gmt":"2026-11-06T06:01:20","guid":{"rendered":"http:\/\/pro369.com\/blog\/?p=51"},"modified":"2026-11-06T14:01:20","modified_gmt":"2026-11-06T06:01:20","slug":"wordpress%e8%b3%87%e6%96%99%e5%ba%ab%e6%94%b9%e5%96%84%e6%8a%80%e5%b7%a7%e5%92%8c%e5%b8%b8%e7%94%a8%e7%9a%84mysql%e8%aa%9e%e6%b3%95-2","status":"publish","type":"post","link":"https:\/\/por.tw\/blog\/2026\/11\/06\/wordpress%e8%b3%87%e6%96%99%e5%ba%ab%e6%94%b9%e5%96%84%e6%8a%80%e5%b7%a7%e5%92%8c%e5%b8%b8%e7%94%a8%e7%9a%84mysql%e8%aa%9e%e6%b3%95-2\/","title":{"rendered":"WordPress\u8cc7\u6599\u5eab\u6539\u5584\u6280\u5de7\u548c\u5e38\u7528\u7684MySQL\u8a9e\u6cd5"},"content":{"rendered":"<p><span style=\"background-color: #ffff00; font-size: small; color: #000000\"><strong>WordPress\u7cfb\u7d71\u4f7f\u7528\u6642\u9593\u9577\u4e86\uff0c\u8cc7\u6599\u5eab\u4e2d\u7684\u5197\u9918\u6578\u64da\u5c31\u6703\u5f88\u591a\uff0c\u5b9a\u671f\u6539\u5584\u548c\u6e05\u7406Wordpress\u7684\u8cc7\u6599\u5eab\uff0c\u53ef\u4ee5\u4fdd\u8b49Wordpress\u80fd\u5920\u5feb\u901f\u5de5\u4f5c\u3002<br \/><span style=\"color: #0000ff\">\u9644\u5e368\u500b\u5be6\u7528\u7684Wordpress\u8cc7\u6599\u5eab\u5e38\u7528\u7684Sql\u8a9e\u6cd5\u3002<\/span><\/strong><\/span><\/p>\n<p>\u9996\u5148\uff0c\u505c\u7528\u4e00\u4e9b\u7121\u7528\u7684\u5916\u639b\u7a0b\u5f0f\uff0c\u5c07WordPress\u7cfb\u7d71\u8868\u4e4b\u5916\u7684\u8cc7\u6599\u8868\u90fd\u522a\u9664\uff0c\u53ea\u4fdd\u7559wp_posts\u3001wp_comments\u3001wp_terms\u3001wp_term_relationships\u3001wp_term_taxonomy\u7b49\u7cfb\u7d71\u8cc7\u6599\u8868\u3002<\/p>\n<p>\u5176\u6b21\uff0c\u958b\u555fphpMyadmin\uff0c\u901a\u904eSQL\u8a9e\u6cd5\u9032\u884c\u5197\u9918\u6578\u64da\u522a\u9664\u64cd\u4f5c\u3002\u522a\u9664\u524d\u8a18\u5f97\u5148\u5099\u4efd\u4e00\u4e0b\u3002<\/p>\n<p>\u522a\u9664\u8173\u672c\u4ee3\u78bc\uff1a<\/p>\n<p>&nbsp;&nbsp;&nbsp; DELETE FROM wp_posts WHERE post_type = &#39;revision&#39;;<br \/>&nbsp;&nbsp;&nbsp; DELETE FROM wp_postmeta WHERE meta_key = &#39;_edit_lock&#39;;<br \/>&nbsp;&nbsp;&nbsp; DELETE FROM wp_postmeta WHERE meta_key = &#39;_edit_last&#39;;<\/p>\n<p>\u6700\u5f8c\uff0c\u5728phpMyAdmin\u4e2d\uff0c\u9078\u4e2d\u6240\u6709\u8868\uff0c\u9ede\u300c\u6539\u5584\u8868\u300d\u3002\u7d93\u7531\u9019\u4e00\u756a\u6539\u5584\u64cd\u4f5c\uff0c\u5c31\u53ef\u4ee5\u5c07WordPress\u8cc7\u6599\u5eab\u4e2d\u7684\u5197\u9918\u6578\u64da\u522a\u9664\uff0c\u6539\u5584\u4e86\u8cc7\u6599\u5eab\u7684\u6548\u80fd\u3002<\/p>\n<p>\u5728\u904e\u53bb\u7684\u5341\u5e74\u4e2d\uff0cMySQL\u5df2\u7d93\u6210\u70ba\u5ee3\u53d7\u6b61\u8fce\u7684\u8cc7\u6599\u5eab\uff0c\u800cWordPress\u90e8\u843d\u683c\u4f7f\u7528\u7684\u662fMySQL\u8cc7\u6599\u5eab\uff0c\u96d6\u7136\u4f7f\u7528\u5916\u639b\u7a0b\u5f0f\u53ef\u4ee5\u89e3\u6c7a\u4e00\u4e9b\u554f\u984c\uff0c\u4f46\u662f\u5be6\u73fe\u67d0\u4e9b\u7279\u6b8a\u4efb\u52d9\u7684\u6642\u5019\uff0c\u5728phpMyAdmin\u4e2d\u57f7\u884cSQL\u8a9e\u6cd5\u662f\u6700\u7c21\u6f54\u7684\u65b9\u6cd5\uff0c\u9019\u88e1\u5c31\u7e3d\u7d50\u516b\u500b\u6709\u7528\u7684WordPress\u7cfb\u7d71\u7684SQL\u8a9e\u6cd5\uff0c\u7528\u65bc\u89e3\u6c7a\u4e00\u4e9b\u5be6\u969b\u78b0\u5230\u7684\u554f\u984c\u3002<br \/><span style=\"font-size: small; color: #800000\"><strong><br \/>1\u3001\u5efa\u7acb\u5099\u4efd\u8cc7\u6599\u5eab<\/strong><\/span><\/p>\n<p>\u5099\u4efd\u8cc7\u6599\u5eab\u662f\u9996\u5148\u8981\u505a\u7684\u4e8b\u60c5\uff0c\u53ea\u9700\u8981\u901a\u904e\u4ee5\u4e0b\u65b9\u6cd5\u5c31\u53ef\u4ee5\u7c21\u55ae\u5099\u4efd\u8cc7\u6599\u5eab\uff1a<\/p>\n<p>\u767b\u5165phpMyAdmin\u5f8c\u3002\u9078\u53d6\u4f60\u7684WordPress\u8cc7\u6599\u5eab\uff0c\u7136\u5f8c\u9ede\u64ca\u300c\u532f\u51fa\u300d\u6309\u9215\uff0c\u9078\u53d6\u4e00\u7a2e\u58d3\u7e2e\u6a21\u5f0f\uff08\u53ef\u4ee5\u4f7f\u7528gzip\u6216zip\uff09\u4e26\u9ede\u9078\u300c\u57f7\u884c\u300d\u6309\u9215\uff0c\u7576\u700f\u89bd\u5668\u63d0\u793a\u662f\u5426\u4e0b\u8f09\u7684\u6642\u5019\uff0c\u9ede\u300c\u662f\u300d\uff0c\u5c07\u8cc7\u6599\u5eab\u6a94\u6848\u4e0b\u8f09\u5230\u672c\u5730\u3002<br \/><span style=\"font-size: small; color: #008000\"><strong><br \/>2\u3001\u6279\u6b21\u522a\u9664\u6587\u7ae0\u8ffd\u8e64\u4fee\u8a02<\/strong><\/span><\/p>\n<p>WordPress2.6\u4ee5\u5f8c\u7684\u7248\u672c\u589e\u52a0\u4e86\u4e00\u500bPost revisions\u529f\u80fd\uff0c\u96d6\u7136\u6709\u9ede\u7528\uff0c\u4f46\u6587\u7ae0\u8ffd\u8e64\u4fee\u8a02\u589e\u52a0\u4e86\u4f60\u8cc7\u6599\u5eab\u7684\u5927\u5c0f\uff0c\u6211\u5011\u53ef\u4ee5\u9078\u53d6\u6279\u6b21\u522a\u9664\u3002<\/p>\n<p>\u767b\u5165phpMyAdmin\u5f8c\u57f7\u884c\u4e0b\u9762\u7684SQL\u8a9e\u6cd5\u5373\u53ef\u6279\u6b21\u522a\u9664\u3002<\/p>\n<p>&nbsp;&nbsp;&nbsp; DELETE FROM wp_posts WHERE post_type = &quot;revision&quot;;<\/p>\n<p><span style=\"font-size: small; color: #0000ff\"><strong>3\u3001\u6279\u6b21\u522a\u9664\u5783\u573e\u8a55\u8ad6<\/strong><\/span><\/p>\n<p>\u4e00\u500b\u771f\u5be6\u7684\u6545\u4e8b\u662f\uff0c\u9583\u96fb\u90e8\u843d\u683c\u7684\u4e00\u500b\u670b\u53cb\u5728\u7db2\u4e0a\u5efa\u7acb\u4e86\u4e00\u500b\u90e8\u843d\u683c\uff0c\u6709\u6b21\u4ed6\u82b1\u4e86\u5e7e\u5929\u6642\u9593\u5916\u51fa\u5ea6\u5047\uff0c\u6c92\u6709\u4e0a\u7db2\uff0c\u7576\u4ed6\u56de\u4f86\u7684\u6642\u5019\uff0c\u767b\u5165\u81ea\u5df1\u7684\u90e8\u843d\u683c\uff0c\u770b\u5230\u67095000\u591a\u689d\u8a55\u8ad6\u7b49\u5f85\u5be9\u6838\uff0c\u7576\u7136\uff0c\u5927\u591a\u6578\u90fd\u662f\u5783\u573e\u8a55\u8ad6\uff0c\u8981\u624b\u52d5\u522a\u9664\u9019\u4e9b\u8a55\u8ad6\u8981\u82b1\u5927\u91cf\u6642\u9593\uff0c\u56e0\u6b64\u6211\u5011\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u8fa6\u6cd5\u3002<\/p>\n<p>\u767b\u5165phpMyAdmin\u5f8c\u57f7\u884c\u4e0b\u9762\u7684SQL\u8a9e\u6cd5\u3002<\/p>\n<p>&nbsp;&nbsp;&nbsp; DELETE from wp_comments WHERE comment_approved = &#39;0&#39;;<\/p>\n<p>\u8981\u5c0f\u5fc3\uff0c\u96d6\u7136\u9019\u7a2e\u89e3\u6c7a\u5c08\u6848\u5c0d\u65bc\u8655\u7406\u6578\u767e\u842c\u7684\u5783\u573e\u5e73\u90f5\u975e\u5e38\u6709\u7528\uff0c\u4f46\u662f\u4e5f\u6703\u6e05\u9664\u672a\u7d93\u6279\u51c6\u7684\u8a55\u8ad6\uff0c\u56e0\u6b64\u6700\u597d\u9084\u662f\u5b89\u88dd\u4f7f\u7528Akismet\u4f86\u5c0d\u4ed8\u5783\u573e\u8a55\u8ad6\u3002<\/p>\n<p><span style=\"font-size: small; color: #800080\"><strong>4\u3001\u4fee\u6539\u6587\u7ae0\u5c6c\u6027<\/strong><\/span><\/p>\n<p>\u4f60\u5b89\u88ddWordPress\u5f8c\uff0cadmin\u8cec\u6236\u5c31\u5efa\u7acb\u4e86\uff0c\u4e0d\u5c11\u4eba\u90fd\u932f\u8aa4\u7684\u4f7f\u7528\u9019\u500b\u5e33\u865f\u4f86\u5beb\u90e8\u843d\u683c\uff0c\u76f4\u5230\u4ed6\u5011\u8a8d\u8b58\u5230\uff0c\u9019\u4e26\u4e0d\u662f\u500b\u4eba\u5e33\u865f\u3002<\/p>\n<p>\u89e3\u6c7a\u7684\u65b9\u6cd5\uff0c\u6bcf\u7bc7\u6587\u7ae0\u4fee\u6539\u4f5c\u8005\u5c6c\u6027\u9700\u8981\u5927\u91cf\u7684\u6642\u9593\uff0c\u4e0b\u9762\u7684\u9019\u500bSQL\u8a9e\u6cd5\u53ef\u4ee5\u5e6b\u4f60\u5feb\u901f\u5b8c\u6210\u9019\u500b\u529f\u80fd\u3002<\/p>\n<p>\u9996\u5148\u4f60\u8981\u627e\u5230\u4f60\u6b63\u78ba\u7684\u4f7f\u7528\u8005\u540d\uff0c\u4f7f\u7528\u4e0b\u9762\u7684SQL\u8a9e\u6cd5\u53ef\u4ee5\u627e\u5230\u4f60\u7684\u4f7f\u7528\u8005ID\u865f\u3002<\/p>\n<p>&nbsp;&nbsp;&nbsp; SELECT ID, display_name FROM wp_users;<\/p>\n<p>\u5047\u8a2d\u9019\u500bID\u70baNEW_AUTHOR_ID\uff0c\u800c\u7ba1\u7406\u54e1admin\u7684ID\u70baOLD_AUTHOR_ID\uff0c\u63a5\u8457\uff0c\u904b\u884c\u4e0b\u9762\u7684SQL\u8a9e\u6cd5\u3002<\/p>\n<p>&nbsp;&nbsp;&nbsp; UPDATE wp_posts SET post_author=NEW_AUTHOR_ID WHERE post_author=OLD_AUTHOR_ID;<\/p>\n<p><span style=\"font-size: small; color: #008080\"><strong>5\u3001\u624b\u52d5\u91cd\u8a2d\u5bc6\u78bc<\/strong><\/span><\/p>\n<p>\u5f88\u591a\u4eba\u70ba\u4e86\u4fdd\u8b77\u81ea\u5df1\u7684\u90e8\u843d\u683c\u4e0d\u88ab\u4eba\u9ed1\u6389\uff0c\u4f7f\u7528\u4e86\u5f88\u8907\u96dc\u7684\u5bc6\u78bc\uff0c\u9019\u96d6\u7136\u662f\u4e00\u4ef6\u597d\u4e8b\uff0c\u4f46\u4e5f\u7d93\u5e38\u6703\u767c\u751f\u907a\u5fd8\u7ba1\u7406\u54e1\u5bc6\u78bc\u7684\u4e8b\u60c5\u3002<\/p>\n<p>\u7576\u7136\uff0c\u901a\u904e\u96fb\u5b50\u4fe1\u4ef6\u53ef\u4ee5\u50b3\u9001\u5230\u7d66\u4f60WordPress\u91cd\u8a2d\u5bc6\u78bc\u7684\u9023\u7d50\uff0c\u4f46\u5982\u679c\u4f60\u7121\u6cd5\u8a2a\u554f\u4f60\u7684\u4fe1\u4ef6\u4f4d\u5740\uff0c\u90a3\u9ebc\u5c31\u53ea\u597d\u4f7f\u7528\u4e0b\u9762\u7684SQL\u8a9e\u6cd5\u4f86\u91cd\u8a2d\u4f60\u7684\u5bc6\u78bc\u4e86\u3002<\/p>\n<p>UPDATE wp_users SET user_pass = MD5(&#39;PASSWORD&#39;) WHERE wp_users.user_login =&#39;admin&#39; LIMIT 1;<\/p>\n<p>MD5\u662fMySQL\u5167\u5efa\u7684\u54c8\u5e0c\u51fd\u6578\uff0c\u7528\u65bc\u5c07\u5bc6\u78bc\u8f49\u63db\u70ba\u6563\u5217\u503c\u3002<\/p>\n<p><span style=\"font-size: small; color: #ff00ff\"><strong>6\u3001\u8b8a\u66f4WordPress\u7684\u529f\u80fd\u8b8a\u6578\u540d<\/strong><\/span><\/p>\n<p>\u4f60\u53ef\u80fd\u6709\u6642\u5019\u6703\u60f3\u8981\u8b8a\u66f4\u4f60\u90e8\u843d\u683c\u7684\u529f\u80fd\u8b8a\u6578\u540d\uff0c\u4f46\u662fWordPress\u6703\u5c07\u4f60\u7684\u529f\u80fd\u8b8a\u6578\u540d\u5b58\u5132\u5728\u8cc7\u6599\u5eab\u4e2d\uff0c\u56e0\u6b64\u4f60\u8981\u4f7f\u7528\u4e0b\u9762\u7684SQL\u8a9e\u6cd5\u4f86\u4fee\u6539\u3002<\/p>\n<p>&nbsp;&nbsp;&nbsp; UPDATE wp_options SET option_value = replace(option_value, &#39;http:\/\/www.oldsite.com&#39;, &#39;http:\/\/www.newsite.com&#39;) WHERE option_name = &#39;home&#39; OR option_name = &#39;siteurl&#39;;<\/p>\n<p>\u63a5\u8457\uff0c\u4f60\u9084\u8981\u4f7f\u7528\u4e0b\u9762\u7684SQL\u5c07\u6587\u7ae0\u7684GUID\u4e5f\u9032\u884c\u4fee\u6539\u3002<\/p>\n<p>&nbsp;&nbsp;&nbsp; UPDATE wp_posts SET guid = replace(guid, &#39;http:\/\/www.oldsite.com&#39;,&#39;http:\/\/www.newsite.com&#39;);<\/p>\n<p>\u6700\u5f8c\uff0c\u4f7f\u7528\u4e0b\u9762\u7684\u8a9e\u6cd5\u5c07\u6587\u7ae0\u88e1\u6240\u6709\u820a\u529f\u80fd\u8b8a\u6578\u540d\u7f6e\u63db\u70ba\u65b0\u529f\u80fd\u8b8a\u6578\u540d\u3002<\/p>\n<p>&nbsp;&nbsp;&nbsp; UPDATE wp_posts SET post_content = replace(post_content, &#39;http:\/\/www.oldsite.com&#39;, &#39;http:\/\/www.newsite.com&#39;);<\/p>\n<p><span style=\"font-size: small; color: #ff0000\"><strong>7\u3001\u986f\u793aSQL\u67e5\u8a62\u6578\u91cf<\/strong><\/span><\/p>\n<p>\u5728\u4f60\u6709\u8a71\u90e8\u843d\u683c\u6548\u80fd\u7684\u6642\u5019\uff0c\u77ad\u89e3\u5230\u67e5\u8a62\u8cc7\u6599\u5eab\u7684\u6578\u91cf\u662f\u975e\u5e38\u91cd\u8981\u7684\uff0c\u70ba\u4e86\u6e1b\u5c11\u8cc7\u6599\u5eab\u67e5\u8a62\uff0c\u6211\u5011\u9700\u8981\u77e5\u9053\u5728\u4e00\u500b\u9801\u9762\u4e0a\u5230\u5e95\u6709\u591a\u5c11\u500b\u67e5\u8a62\u3002<\/p>\n<p>\u9019\u4e00\u6b21\uff0c\u4e0d\u9700\u8981\u767b\u5165phpMyAdmin\u4e86\uff0c\u4f60\u53ea\u9700\u8981\u4fee\u6539footer.php\u6a94\u6848\uff0c\u5728\u6a94\u6848\u7d50\u5c3e\u589e\u52a0\u4e0b\u9762\u5e7e\u884c\u4ee3\u78bc\u5373\u53ef\u3002<\/p>\n<p>&nbsp;&nbsp;&nbsp; &lt;?php if (is_user_logged_in()) { ?&gt;<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;?php echo get_num_queries(); ?&gt; queries in &lt;?php timer_stop(1); ?&gt; seconds.<br \/>&nbsp;&nbsp;&nbsp; &lt;?php } ?&gt;<\/p>\n<p><span style=\"font-size: small; color: #800000\"><strong>8\u3001\u6062\u5fa9\u4f60\u7684WordPress\u8cc7\u6599\u5eab<\/strong><\/span><\/p>\n<p>\u7576\u4f60\u7684\u8cc7\u6599\u5eab\u56e0\u70ba\u67d0\u4e9b\u539f\u56e0\uff08\u9ed1\u5ba2\u6216\u662f\u5347\u7d1a\u932f\u8aa4\uff09\u88ab\u640d\u58de\u6216\u662f\u4e1f\u5931\u4e86\uff0c\u5982\u679c\u4f60\u6709\u5099\u4efd\u7684\u8a71\uff0c\u90a3\u53ef\u4ee5\u6062\u5fa9\u4f60\u7684WordPress\u8cc7\u6599\u5eab\u3002<\/p>\n<p>\u767b\u5165phpMyAdmin\uff0c\u9078\u53d6\u4f60\u7684WordPress\u8cc7\u6599\u5eab\uff0c\u9ede\u300c\u532f\u5165\u300d\u6309\u9215\uff0c\u9ede\u300c\u700f\u89bd\u300d\u6309\u9215\uff0c\u7136\u5f8c\u5f9e\u4f60\u7684\u786c\u789f\u9078\u53d6\u5099\u4efd\u6a94\u6848\uff0c\u9ede\u300c\u57f7\u884c\u300d\u6309\u9215\u5c31\u53ef\u4ee5\u5c07\u8cc7\u6599\u5eab\u532f\u5165\u3002<\/p>\n<p>\u5982\u679c\u9806\u5229\u7684\u8a71\uff0c\u4f60\u7684WordPress\u529f\u80fd\u5c07\u6703\u6062\u5fa9\u6a19\u6e96\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"post-excerpt\"><p>WordPress\u7cfb\u7d71\u4f7f\u7528\u6642\u9593\u9577\u4e86\uff0c\u8cc7\u6599\u5eab\u4e2d\u7684\u5197\u9918\u6578\u64da\u5c31\u6703\u5f88\u591a\uff0c\u5b9a\u671f\u6539\u5584\u548c\u6e05\u7406Wordpress\u7684\u8cc7\u6599\u5eab\uff0c\u53ef\u4ee5<\/p>\n<\/div>","protected":false},"author":1,"featured_media":520,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[34],"class_list":["post-9039","post","type-post","status-publish","format-standard","has-post-thumbnail","category-wordpress-","tag-wordpress-"],"_links":{"self":[{"href":"https:\/\/por.tw\/blog\/wp-json\/wp\/v2\/posts\/9039","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/por.tw\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/por.tw\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/por.tw\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/por.tw\/blog\/wp-json\/wp\/v2\/comments?post=9039"}],"version-history":[{"count":0,"href":"https:\/\/por.tw\/blog\/wp-json\/wp\/v2\/posts\/9039\/revisions"}],"wp:attachment":[{"href":"https:\/\/por.tw\/blog\/wp-json\/wp\/v2\/media?parent=9039"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/por.tw\/blog\/wp-json\/wp\/v2\/categories?post=9039"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/por.tw\/blog\/wp-json\/wp\/v2\/tags?post=9039"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}