<?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://zhiqiang.org/blog/tag/mysql/feed" rel="self" type="application/rss+xml" />
	<link>http://zhiqiang.org/blog</link>
	<description>理工科背景的证券从业人员</description>
	<lastBuildDate>Tue, 17 Jan 2012 15:12:52 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>搞定乱码，WordPress搬家到dreamhost</title>
		<link>http://zhiqiang.org/blog/it/to-get-gibberish-wordpress-move-to-dreamhost.html</link>
		<comments>http://zhiqiang.org/blog/it/to-get-gibberish-wordpress-move-to-dreamhost.html#comments</comments>
		<pubDate>Mon, 03 Jul 2006 12:17:48 +0000</pubDate>
		<dc:creator>zhiqiang</dc:creator>
				<category><![CDATA[IT技术]]></category>
		<category><![CDATA[记事本]]></category>
		<category><![CDATA[Dreamhost]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[phpmyadmin]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[搬家]]></category>
		<category><![CDATA[数据库]]></category>

		<guid isPermaLink="false">http://zhiqiang.org/blog/359.html</guid>
		<description><![CDATA[博客 » IT技术 » WordPress » 两个月前一时冲动，花了大约80大洋买了一年的dreamhost主机。刚买的时候就试图把Blog搬到它上面去，不过由于数据库的乱码原因，一直没有成功。最近，多个电信的朋友告诉我我的Blog速度&#8220;慢得不能忍受&#8221;，今天下午下定决心搞定数据库，哪知道一下子就弄了4个小时，到现在才基本上搞定。现在正式进入测试期，欢迎报告Bug和异常情况。 先说...]]></description>
			<content:encoded><![CDATA[<p id="breadcrumb" class="breadcrumb"><a href="http://zhiqiang.org/blog/">博客</a> » <a href="http://zhiqiang.org/blog/category/it">IT技术</a> » <a href='http://zhiqiang.org/blog/tag/wordpress'>WordPress</a>  » </p><p>两个月前一时冲动，花了大约80大洋买了一年的<a href="http://dreamhost.com/">dreamhost主机</a>。刚买的时候就试图把Blog搬到它上面去，不过由于数据库的乱码原因，一直没有成功。最近，多个电信的朋友告诉我我的Blog速度&ldquo;慢得不能忍受&rdquo;，今天下午下定决心搞定数据库，哪知道一下子就弄了4个小时，到现在才基本上搞定。现在正式进入测试期，欢迎报告Bug和异常情况。</p>
<p>先说一下我是怎么解决数据库乱码问题的。最开始的时候在phpmyadmin里面直接导入备份文件（使用WordPress自带的database backup生成），最后文章里面大部分显示正常，但是间或的有些汉字变成了乱码（在FireFox下变成两个?号）。在无数次失败的尝试和Baidu的帮助下，最后找到解决方案：</p>
<ol>
<li>使用WordPress自带的database backup生成备份文件（打开这个文件，里面中文是正常的，而如果直接从phpmyadmin里面导出数据库，中文都是乱码）。 </li>
<li>在phpMyadmin中设定MySQL 字符集: UTF-8 Unicode (utf8) （一般来说默认就是这个） </li>
<li>在phpMyadmin中设定MySQL 连接校对: utf8_general_ci </li>
<li><font color="#ff0000">用文本编辑器如EditPlus 打开备份的数据库文件，查找&quot;DEFAULT CHARSET=latin1&quot; 用&quot;DEFAULT CHARSET=utf8&quot;替换。</font> </li>
<li>用phpMyadmin导入上面修改过的备份文件。 </li>
<li>修改wp-includes/wp-db.php內的资料连线设定。详细的修改方式是这样的：<br />$this-&gt;dbh = @mysql_connect($dbhost,$dbuser,$dbpassword);<br />//加上下面这行<br /><code>$this-&gt;query(&quot;SET NAMES 'utf8'&quot; );</code> </li>
</ol>
<p>这样做之后，不但页面上没有乱码，在数据库里面也可以直接看到中文。另外，在解决过程中得到了<a target="_blank" href="http://lucifr.com">Lucifer</a>和<a target="_blank" href="http://sunxiunan.com/">Sunwell</a>帮助，关键的一步从wordpress恢复数据库后乱码问题的解决看来的，一并表示感谢。</p>
<p>我和Dreamhost：</p>
<ul>
<li>我上Dreamhost还是太慢了，特别是它的FTP，无法忍受。 </li>
<li>Dreamhost的CPU速度比我原来的实验室的服务器还要慢，看看页面生成时间，有时候竟然需要2秒以上，郁闷。 </li>
<li>Dreamhost的服务器在国外，教育网访问需要代理，包括我自己，:(。 </li>
<li>不用担心备案问题了，不过我担心Dreamhost整体被封。 </li>
<li>十个月后空间到期后咋办呢？对我来说，搬家很快的，拎着数据库跑就行了。图片啥的我都放到Flickr和Picasa Web上了。不过寻找新空间是个大问题，暂时不管了。 </li>
</ul>
<p>另外，Dreamhost的unix主机的文件名是分大小写的，结果导致我有些ajax程序异常，不过现在已修正。</p>
<div><h4>相关文章</h4><ul><li><a href="http://zhiqiang.org/blog/it/move-to-the-blog-server-bluehost.html">blog服务器搬家到bluehost</a></li><li><a href="http://zhiqiang.org/blog/science/computer-science/move-blogbus-data-to-wordpress.html">BlogBus搬家文件转WordPress导入文件</a></li><li><a href="http://zhiqiang.org/blog/it/dreamhost-on-gzip-cache.html">Dreamhost上的GZIP &#038; Cache</a></li><li><a href="http://zhiqiang.org/blog/it/dreamhost-system-load-average-load-recording-and-analysis.html">Dreamhost系统Load average负载记录和分析</a></li><li><a href="http://zhiqiang.org/blog/it/speedup-blog-optimize-wordpress-database.html">加速blog：监测和优化WordPress数据库</a></li><li><a href="http://zhiqiang.org/blog/science/computer-science/database-query-is-np-hard.html">数据库查询是NP-Hard问题</a></li><li><a href="http://zhiqiang.org/blog/it/change-pivotcache-source.html">动态修改Excel数据表的数据来源</a></li><li><a href="http://zhiqiang.org/blog/it/script-to-add-odbc-source.html">用脚本添加ODBC数据源</a></li><li><a href="http://zhiqiang.org/blog/it/use-adodb-in-matlab.html">Matlab中使用ADODB访问数据库</a></li><li><a href="http://zhiqiang.org/blog/it/bbpress-installation-problems-and-several-plug-ins.html">bbPress的安装问题和几个插件</a></li></ul></div>    <p></p>
    <hr noshade style="margin:0;height:1px" />
    <p>&copy; zhiqiang for <a href="http://zhiqiang.org/blog">阅微堂</a>, 2006. | <a href="http://zhiqiang.org/blog/it/to-get-gibberish-wordpress-move-to-dreamhost.html">&#38142;&#25509;</a> | <a href="http://zhiqiang.org/blog/it/to-get-gibberish-wordpress-move-to-dreamhost.html#comments">46 &#26465;&#35780;&#35770;</a></p>]]></content:encoded>
			<wfw:commentRss>http://zhiqiang.org/blog/it/to-get-gibberish-wordpress-move-to-dreamhost.html/feed</wfw:commentRss>
		<slash:comments>46</slash:comments>
		</item>
	</channel>
</rss>

