<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>润物无声 &#187; 效率工具</title>
	<atom:link href="http://blog.zhourunsheng.com/tag/%e6%95%88%e7%8e%87%e5%b7%a5%e5%85%b7/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.zhourunsheng.com</link>
	<description>天空一朵雨做的云</description>
	<lastBuildDate>Sat, 08 May 2021 05:17:21 +0000</lastBuildDate>
	<language>zh-CN</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>https://wordpress.org/?v=4.1.41</generator>
	<item>
		<title>WordPress中实用的SQl语句</title>
		<link>http://blog.zhourunsheng.com/2012/06/wordpress%e4%b8%ad%e5%ae%9e%e7%94%a8%e7%9a%84sql%e8%af%ad%e5%8f%a5/</link>
		<comments>http://blog.zhourunsheng.com/2012/06/wordpress%e4%b8%ad%e5%ae%9e%e7%94%a8%e7%9a%84sql%e8%af%ad%e5%8f%a5/#comments</comments>
		<pubDate>Tue, 05 Jun 2012 05:40:10 +0000</pubDate>
		<dc:creator><![CDATA[润物无声]]></dc:creator>
				<category><![CDATA[Web设计]]></category>
		<category><![CDATA[Mysql]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[效率工具]]></category>

		<guid isPermaLink="false">http://blog.zhourunsheng.com/?p=1621</guid>
		<description><![CDATA[<p>利用wordpress搭建个人博客比较方便，有时候会涉及到博客内容的批量变更，本文分享几个有效的sql语句来方 [&#8230;]</p>
<p><a rel="nofollow" href="http://blog.zhourunsheng.com/2012/06/wordpress%e4%b8%ad%e5%ae%9e%e7%94%a8%e7%9a%84sql%e8%af%ad%e5%8f%a5/">WordPress中实用的SQl语句</a>，首发于<a rel="nofollow" href="http://blog.zhourunsheng.com">润物无声</a>。</p>
]]></description>
				<content:encoded><![CDATA[<p>利用wordpress搭建个人博客比较方便，有时候会涉及到博客内容的批量变更，本文分享几个有效的sql语句来方便的进行内容更新。</p>
<h2>数据库备份</h2>
<p>在做具体的修改以前，建议先备份数据库，phpMyAdmin备份步骤如下：</p>
<ul>
<li>Login to your <strong>phpMyAdmin</strong>.</li>
<li>Select your WordPress database.</li>
<li>Click on <strong>Export</strong> at the top of the navigation.</li>
<li>Select the tables you want to backup, or select all tables to backup the whole database.</li>
<li>Select SQL to export as <strong>.sql</strong> extension.</li>
<li>Check the "Save as file" checkbox.</li>
<li>Choose compression type, select <strong>gzipped</strong> to compress the database to a smaller size.</li>
<li>Finally click <strong>Go</strong>, and a download window will prompt you to save your backup database file.</li>
</ul>
<p><span id="more-1621"></span></p>
<h2>实用SQL语句</h2>
<p><strong>变更博客网址 Siteurl &amp; Homeurl</strong></p>
<pre>UPDATE wp_options SET option_value = replace(option_value, 'http://www.oldsiteurl.com', 'http://www.newsiteurl.com') WHERE option_name = 'home' OR option_name = 'siteurl';</pre>
<p><strong>变更博文归属GUID</strong></p>
<pre>UPDATE wp_posts SET guid = REPLACE (guid, 'http://www.oldsiteurl.com', 'http://www.newsiteurl.com');</pre>
<p><strong>变更博文中的URL引用</strong></p>
<pre>UPDATE wp_posts SET post_content = REPLACE (post_content, 'http://www.oldsiteurl.com', 'http://www.newsiteurl.com');</pre>
<p><strong>变更博文中的图片加载引用</strong></p>
<pre>UPDATE wp_posts SET post_content = REPLACE (post_content, 'src="http://www.oldsiteurl.com', 'src="http://yourcdn.newsiteurl.com');
UPDATE wp_posts SET guid = REPLACE (guid, 'http://www.oldsiteurl.com', 'http://yourcdn.newsiteurl.com') WHERE post_type = 'attachment';</pre>
<p><strong>变更博文Meta信息中的URL引用</strong></p>
<pre>UPDATE wp_postmeta SET meta_value = REPLACE (meta_value, 'http://www.oldsiteurl.com','http://www.newsiteurl.com');</pre>
<p><strong>变更默认的管理员"Admin"用户名</strong></p>
<pre>UPDATE wp_users SET user_login = 'Your New Username' WHERE user_login = 'Admin';</pre>
<p><strong>密码重置</strong></p>
<pre>UPDATE wp_users SET user_pass = MD5( 'new_password' ) WHERE user_login = 'your-username';</pre>
<p><strong>变更博文归属（从作者B到作者A）</strong></p>
<p>首先需要获得两个作者的ID，可以通过管理员面板来浏览作者的详细信息，此时查看浏览器地址栏中的链接，寻找"user_id=?"</p>
<pre>UPDATE wp_posts SET post_author = 'new-author-id' WHERE post_author = 'old-author-id';</pre>
<p><strong>删除博文修订记录</strong></p>
<pre>DELETE a,b,c FROM wp_posts a
LEFT JOIN wp_term_relationships b ON (a.ID = b.object_id)
LEFT JOIN wp_postmeta c ON (a.ID = c.post_id)
WHERE a.post_type = 'revision'</pre>
<p><strong>删除博文指定的Meta信息</strong></p>
<pre>DELETE FROM wp_postmeta WHERE meta_key = 'your-meta-key';</pre>
<p><strong>收集评论的Email地址</strong></p>
<pre>SELECT DISTINCT comment_author_email FROM wp_comments;</pre>
<p><strong>删除博文的Pingback</strong></p>
<pre>DELETE FROM wp_comments WHERE comment_type = 'pingback';</pre>
<p><strong>删除所有的垃圾评论</strong></p>
<ul>
<li>0 = Comment Awaiting Moderation</li>
<li>1 = Approved Comment</li>
<li>spam = Comment marked as Spam</li>
</ul>
<pre>DELETE FROM wp_comments WHERE comment_approved = 'spam';</pre>
<p><strong>删除没有使用的Tags</strong></p>
<pre>SELECT * From wp_terms wt
INNER JOIN wp_term_taxonomy wtt ON wt.term_id=wtt.term_id WHERE wtt.taxonomy='post_tag' AND wtt.count=0;</pre>
<h2>参照文章</h2>
<ul>
<li><a href="http://www.onextrapixel.com/2010/01/30/13-useful-wordpress-sql-queries-you-wish-you-knew-earlier/">13 Useful WordPress SQL Queries You Wish You Knew Earlier</a></li>
</ul>
<p><a rel="nofollow" href="http://blog.zhourunsheng.com/2012/06/wordpress%e4%b8%ad%e5%ae%9e%e7%94%a8%e7%9a%84sql%e8%af%ad%e5%8f%a5/">WordPress中实用的SQl语句</a>，首发于<a rel="nofollow" href="http://blog.zhourunsheng.com">润物无声</a>。</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.zhourunsheng.com/2012/06/wordpress%e4%b8%ad%e5%ae%9e%e7%94%a8%e7%9a%84sql%e8%af%ad%e5%8f%a5/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
