<?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; Mysql</title>
	<atom:link href="http://blog.zhourunsheng.com/tag/mysql/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>
		<item>
		<title>Java PHP Json Mysql 中文乱码问题之解决</title>
		<link>http://blog.zhourunsheng.com/2012/06/java-php-json-mysql-%e4%b8%ad%e6%96%87%e4%b9%b1%e7%a0%81%e9%97%ae%e9%a2%98%e4%b9%8b%e8%a7%a3%e5%86%b3/</link>
		<comments>http://blog.zhourunsheng.com/2012/06/java-php-json-mysql-%e4%b8%ad%e6%96%87%e4%b9%b1%e7%a0%81%e9%97%ae%e9%a2%98%e4%b9%8b%e8%a7%a3%e5%86%b3/#comments</comments>
		<pubDate>Fri, 01 Jun 2012 03:15:55 +0000</pubDate>
		<dc:creator><![CDATA[润物无声]]></dc:creator>
				<category><![CDATA[程序设计]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Json]]></category>
		<category><![CDATA[Mysql]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[中文乱码]]></category>

		<guid isPermaLink="false">http://blog.zhourunsheng.com/?p=1619</guid>
		<description><![CDATA[<p>问题 客户端采用Java语言编写，服务器端采用PHP语言编写，数据库采用Mysql存储，客户端和服务器之间的交 [&#8230;]</p>
<p><a rel="nofollow" href="http://blog.zhourunsheng.com/2012/06/java-php-json-mysql-%e4%b8%ad%e6%96%87%e4%b9%b1%e7%a0%81%e9%97%ae%e9%a2%98%e4%b9%8b%e8%a7%a3%e5%86%b3/">Java PHP Json Mysql 中文乱码问题之解决</a>，首发于<a rel="nofollow" href="http://blog.zhourunsheng.com">润物无声</a>。</p>
]]></description>
				<content:encoded><![CDATA[<h2>问题</h2>
<p>客户端采用Java语言编写，服务器端采用PHP语言编写，数据库采用Mysql存储，客户端和服务器之间的交互采用Json，在传递英文数据的时候没有问题，当传递中文数据数据的时候，就会出现中文乱码问题，mysql里面的中文全部变成问号了。</p>
<h2>解决方案</h2>
<ul>
<li>Mysql数据库，数据表，数据字段采用统一编码UTF-8, 如 utf8_general_ci</li>
<li>客户端Java字符串转成json格式的时候先进行urlencode处理
<pre>JSONObject jo = new JSONObject();
//jo.accumulate("note", note);
jo.accumulate("note", URLEncoder.encode(note));</pre>
</li>
<li>服务器端PHP转换json格式后，插入数据库前先进行urldecode处理
<pre>$data = array(
    'meta_key' =&gt; 'note',
    //'meta_value' =&gt; $params['note'],
    'meta_value' =&gt; urldecode($params['note']),
);</pre>
</li>
<li>经过以上的步骤处理，可完美解决中文乱码问题</li>
</ul>
<p><a rel="nofollow" href="http://blog.zhourunsheng.com/2012/06/java-php-json-mysql-%e4%b8%ad%e6%96%87%e4%b9%b1%e7%a0%81%e9%97%ae%e9%a2%98%e4%b9%8b%e8%a7%a3%e5%86%b3/">Java PHP Json Mysql 中文乱码问题之解决</a>，首发于<a rel="nofollow" href="http://blog.zhourunsheng.com">润物无声</a>。</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.zhourunsheng.com/2012/06/java-php-json-mysql-%e4%b8%ad%e6%96%87%e4%b9%b1%e7%a0%81%e9%97%ae%e9%a2%98%e4%b9%8b%e8%a7%a3%e5%86%b3/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>MySQL在线资源与手册</title>
		<link>http://blog.zhourunsheng.com/2011/07/mysql%e5%9c%a8%e7%ba%bf%e8%b5%84%e6%ba%90%e4%b8%8e%e6%89%8b%e5%86%8c/</link>
		<comments>http://blog.zhourunsheng.com/2011/07/mysql%e5%9c%a8%e7%ba%bf%e8%b5%84%e6%ba%90%e4%b8%8e%e6%89%8b%e5%86%8c/#comments</comments>
		<pubDate>Wed, 27 Jul 2011 03:58:06 +0000</pubDate>
		<dc:creator><![CDATA[润物无声]]></dc:creator>
				<category><![CDATA[程序设计]]></category>
		<category><![CDATA[Mysql]]></category>
		<category><![CDATA[在线资源]]></category>

		<guid isPermaLink="false">http://blog.zhourunsheng.com/?p=503</guid>
		<description><![CDATA[<p>MySQL作为现在比较流行的开源数据库系统，在中小型项目的开发中使用的比较多，本文收集了一些实用的在线资源可以 [&#8230;]</p>
<p><a rel="nofollow" href="http://blog.zhourunsheng.com/2011/07/mysql%e5%9c%a8%e7%ba%bf%e8%b5%84%e6%ba%90%e4%b8%8e%e6%89%8b%e5%86%8c/">MySQL在线资源与手册</a>，首发于<a rel="nofollow" href="http://blog.zhourunsheng.com">润物无声</a>。</p>
]]></description>
				<content:encoded><![CDATA[<p>MySQL作为现在比较流行的开源数据库系统，在中小型项目的开发中使用的比较多，本文收集了一些实用的在线资源可以方便MySQL数据库的学习和在线手册的参考。</p>
<p><img title="mysql-logo" src="http://blog.zhourunsheng.com/wp-content/uploads/2011/07/mysql-logo.jpg" alt="mysql-logo" width="397" height="230" /></p>
<p><span id="more-503"></span></p>
<h3>1)<a href="http://www.mysql.com/"> Official Home Of MySql</a></h3>
<p><img title="Official Home Of MySql" src="http://blog.zhourunsheng.com/wp-content/uploads/2011/07/Official-Home-Of-MySql.png" alt="Official Home Of MySql" width="580" height="252" /></p>
<h3>2) <a href="http://www.w3schools.com/php/php_mysql_intro.asp">W3Schools.com</a></h3>
<p><img title="W3Schools-com" src="http://blog.zhourunsheng.com/wp-content/uploads/2011/07/W3Schools-com.png" alt="W3Schools-com" width="550" height="271" /></p>
<h3>3)<a href="http://www.analysisandsolutions.com/code/mysql-tutorial.htm"> MySql Basics</a></h3>
<p><img title="MySql Basics" src="http://blog.zhourunsheng.com/wp-content/uploads/2011/07/MySql-Basics.png" alt="MySql Basics" width="550" height="287" /></p>
<h3>4) <a href="http://www.tutorialized.com/tutorials/MySQL/1">Tutorialized.com</a></h3>
<p><img title="Tutorialized-com" src="http://blog.zhourunsheng.com/wp-content/uploads/2011/07/Tutorialized-com.png" alt="Tutorialized-com" width="550" height="264" /></p>
<h3>5) <a href="http://www.tizag.com/mysqlTutorial/index.php">Tizag MySql Tutorials</a></h3>
<p><img title="Tizag MySql Tutorials" src="http://blog.zhourunsheng.com/wp-content/uploads/2011/07/Tizag-MySql-Tutorials.png" alt="Tizag MySql Tutorials" width="550" height="341" /></p>
<h3>6)<a href="http://www.tutorialspoint.com/mysql/index.htm"> Tutorialspoint.com</a></h3>
<p><img title="Tutorialspoint-com" src="http://blog.zhourunsheng.com/wp-content/uploads/2011/07/Tutorialspoint-com.png" alt="Tutorialspoint-com" width="550" height="297" /></p>
<h3>7)<a href="http://forge.mysql.com/"> MySql Forge</a></h3>
<p><img title="MySql Forge" src="http://blog.zhourunsheng.com/wp-content/uploads/2011/07/MySql-Forge.png" alt="MySql Forge" width="550" height="236" /></p>
<h3>8)<a href="http://forums.mysql.com/">Official MySql Forum</a></h3>
<p><img title="Official MySql Forum" src="http://blog.zhourunsheng.com/wp-content/uploads/2011/07/Official-MySql-Forum.png" alt="Official MySql Forum" width="550" height="228" /></p>
<h3>9)<a href="http://forums.devshed.com/mysql-help-4/"> Devshed.com</a></h3>
<p><img title="Devshed-com" src="http://blog.zhourunsheng.com/wp-content/uploads/2011/07/Devshed-com.png" alt="Devshed-com" width="550" height="246" /></p>
<h3>10)<a href="http://www.sitepoint.com/"> Sitepoint.com</a></h3>
<p><img title="Sitepoint-com" src="http://blog.zhourunsheng.com/wp-content/uploads/2011/07/Sitepoint-com.png" alt="Sitepoint-com" width="550" height="246" /></p>
<h3>11)<a href="http://planet.mysql.com/">Planet MySql</a></h3>
<p><img title="Planet MySql" src="http://blog.zhourunsheng.com/wp-content/uploads/2011/07/Planet-MySql.png" alt="Planet MySql" width="550" height="261" /></p>
<h3>12)<a href="http://www.mysqlperformanceblog.com/">MySql Performance Blog</a></h3>
<p><img title="MySql Performance Blog" src="http://blog.zhourunsheng.com/wp-content/uploads/2011/07/MySql-Performance-Blog.png" alt="MySql Performance Blog" width="550" height="261" /></p>
<h3>13)<a href="http://www.sql.org/">Sql.org</a></h3>
<p><img title="Sql-org" src="http://blog.zhourunsheng.com/wp-content/uploads/2011/07/Sql-org.png" alt="Sql-org" width="550" height="261" /></p>
<h3>14)<a href="http://www.roseindia.net/mysql/">RoseIndia</a></h3>
<p><img title="RoseIndia" src="http://blog.zhourunsheng.com/wp-content/uploads/2011/07/RoseIndia.png" alt="RoseIndia" width="550" height="261" /></p>
<h3>15)<a href="http://www.webdevelopersnotes.com/tutorials/sql/mysql_tutorial_what_next.php3">WebDevelopersNotes</a></h3>
<p><img title="WebDevelopersNotes" src="http://blog.zhourunsheng.com/wp-content/uploads/2011/07/WebDevelopersNotes.png" alt="WebDevelopersNotes" width="550" height="261" /></p>
<p><a rel="nofollow" href="http://blog.zhourunsheng.com/2011/07/mysql%e5%9c%a8%e7%ba%bf%e8%b5%84%e6%ba%90%e4%b8%8e%e6%89%8b%e5%86%8c/">MySQL在线资源与手册</a>，首发于<a rel="nofollow" href="http://blog.zhourunsheng.com">润物无声</a>。</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.zhourunsheng.com/2011/07/mysql%e5%9c%a8%e7%ba%bf%e8%b5%84%e6%ba%90%e4%b8%8e%e6%89%8b%e5%86%8c/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
