<?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.linym.net/archives/tag/mysql/feed" rel="self" type="application/rss+xml" />
	<link>http://blog.linym.net</link>
	<description>我的學習心得、筆記</description>
	<lastBuildDate>Thu, 10 Sep 2009 07:50:41 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>CodeIgniter 設定 MySQL 編碼</title>
		<link>http://blog.linym.net/archives/212</link>
		<comments>http://blog.linym.net/archives/212#comments</comments>
		<pubDate>Sat, 22 Dec 2007 15:21:51 +0000</pubDate>
		<dc:creator>lym520</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[程式筆記]]></category>
		<category><![CDATA[CodeIgniter]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[編碼]]></category>

		<guid isPermaLink="false">http://blog.linym.net/archives/212</guid>
		<description><![CDATA[※ CodeIgniter 1.6 已釋出，不需再做這篇的修正了哦！
先前有提到過 CodeIgniter 這個 PHP Framework，也用它做了幾個 case，當然開發速度不能說快上多少，但確實讓程式碼變得整齊優雅許多。
使用 CI 目前遇到第一個問題是存取 MySQL 資料的問題，在 MySQL 4.1 以後採用了多層式編碼設定，簡單說就是不管是資料庫、資料表、欄位或是 Client 連線階段，都可以分別設定編碼，所以即使 server 都改成了 utf8，PHP 到 MySQL Server 的這個 connection 卻還是預設的(latin1)，許多亂碼就是這樣造成的，應該已經有不少人知道解決方法，就是先送出一個改變編碼的查詢：SET NAMES &#39;charset&#39;。
然而目前 CodeIgniter 並沒有這樣的設計，所以只好自行改 code 囉！
Step1：修改 system/application/config/database.php
增加一項：$db[&#39;default&#39;][&#39;charset&#39;]  = &#34;utf8&#34;;
Step2：修改 system/database/DB_driver.php
在 32 行之後的宣告增加：var $charset        = &#39;&#39;;
接著 96 行的陣列增加：&#39;charset&#39;	=> &#39;&#39;,
Step3：修改 system/database/drivers/mysql/mysql_driver.php
74 行 [...]]]></description>
			<content:encoded><![CDATA[<p><strong>※ CodeIgniter 1.6 已釋出，不需再做這篇的修正了哦！</strong></p>
<p>先前有<a href="http://blog.linym.net/archives/162">提到</a>過 <a href="http://codeigniter.com/" target="_blank">CodeIgniter</a> 這個 PHP Framework，也用它做了幾個 case，當然開發速度不能說快上多少，但確實讓程式碼變得整齊優雅許多。</p>
<p>使用 CI 目前遇到第一個問題是存取 MySQL 資料的問題，在 MySQL 4.1 以後採用了多層式編碼設定，簡單說就是不管是資料庫、資料表、欄位或是 Client 連線階段，都可以分別設定編碼，所以即使 server 都改成了 utf8，PHP 到 MySQL Server 的這個 connection 卻還是預設的(latin1)，許多亂碼就是這樣造成的，應該已經有不少人知道解決方法，就是先送出一個改變編碼的查詢：SET NAMES &#39;charset&#39;。<br />
然而目前 CodeIgniter 並沒有這樣的設計，所以只好自行改 code 囉！</p>
<p><strong>Step1：修改 system/application/config/database.php</strong><br />
增加一項：$db[&#39;default&#39;][&#39;charset&#39;]  = &quot;utf8&quot;;</p>
<p><strong>Step2：修改 system/database/DB_driver.php</strong><br />
在 32 行之後的宣告增加：var $charset        = &#39;&#39;;<br />
接著 96 行的陣列增加：&#39;charset&#39;	=> &#39;&#39;,</p>
<p><strong>Step3：修改 system/database/drivers/mysql/mysql_driver.php</strong><br />
74 行 return 前加入：</p>
<pre title="code" class="php">

if (!empty($this-&gt;charset))
{
    @mysql_query(&quot;SET NAMES $this-&gt;charset&quot;);
}
</pre>
<p>這樣就 ok 了，如果使用 mysqli 請如法炮製。另外如果主機環境符合，可使用 PHP 內建函式來設定：</p>
<pre title="code" class="php">

// PHP &gt;= 5.2.3，MySQL &gt;= 5.0.7 for mysql
@mysql_set_charset($this-&gt;charset, $this-&gt;conn_id);
// PHP &gt;= 5.0.5，MySQL &gt;= 5.0.6 for mysqli
@mysqli_set_charset($this-&gt;conn_id, $this-&gt;charset);
</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.linym.net/archives/212/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>可攜式 APM 網頁伺服器</title>
		<link>http://blog.linym.net/archives/127</link>
		<comments>http://blog.linym.net/archives/127#comments</comments>
		<pubDate>Sun, 03 Jun 2007 02:21:57 +0000</pubDate>
		<dc:creator>lym520</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Server]]></category>
		<category><![CDATA[系統筆記]]></category>
		<category><![CDATA[Apache]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Portable]]></category>
		<category><![CDATA[伺服器]]></category>

		<guid isPermaLink="false">http://lym.fyman.idv.tw/blog/archives/127</guid>
		<description><![CDATA[本文已移至新分頁：http://blog.linym.net/portableapm
]]></description>
			<content:encoded><![CDATA[<p>本文已移至新分頁：<a href="http://blog.linym.net/portableapm">http://blog.linym.net/portableapm</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.linym.net/archives/127/feed</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>MySQL 遠端連線設定</title>
		<link>http://blog.linym.net/archives/96</link>
		<comments>http://blog.linym.net/archives/96#comments</comments>
		<pubDate>Sat, 13 May 2006 03:27:58 +0000</pubDate>
		<dc:creator>lym520</dc:creator>
				<category><![CDATA[Server]]></category>
		<category><![CDATA[系統筆記]]></category>
		<category><![CDATA[MySQL]]></category>

		<guid isPermaLink="false">http://lym.fyman.idv.tw/blog/archives/96</guid>
		<description><![CDATA[有些主機空間不開放使用 MySQL，這時就可以自己架一台 MySQL Server 並設定允許外部連線，讓沒有 MySQL 的主機也能使用。
方法很簡單，只要兩個關鍵步驟即可：
1) 開啟 TCP 3306 (預設 MySQL Port)。
2) 新增一個 User，主機(Host) 為允許連線的網域或 IP，如果不限制可以用「%」表任何主機。
如果不行請檢查 mysql 設定檔 (my.ini 或 my.cnf)，註解下面文字
skip-networking
bind-address=127.0.0.1
]]></description>
			<content:encoded><![CDATA[<p>有些主機空間不開放使用 MySQL，這時就可以自己架一台 MySQL Server 並設定允許外部連線，讓沒有 MySQL 的主機也能使用。<br />
方法很簡單，只要兩個關鍵步驟即可：</p>
<blockquote><p>1) 開啟 TCP 3306 (預設 MySQL Port)。<br />
2) 新增一個 User，主機(Host) 為允許連線的網域或 IP，如果不限制可以用「%」表任何主機。</p></blockquote>
<p>如果不行請檢查 mysql 設定檔 (my.ini 或 my.cnf)，註解下面文字<br />
skip-networking<br />
bind-address=127.0.0.1</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.linym.net/archives/96/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MySQL 4.1 + phpMyAdmin 問題</title>
		<link>http://blog.linym.net/archives/6</link>
		<comments>http://blog.linym.net/archives/6#comments</comments>
		<pubDate>Sun, 28 Nov 2004 02:20:07 +0000</pubDate>
		<dc:creator>lym520</dc:creator>
				<category><![CDATA[Windows]]></category>
		<category><![CDATA[系統筆記]]></category>
		<category><![CDATA[軟體筆記]]></category>
		<category><![CDATA[MySQL]]></category>

		<guid isPermaLink="false">http://lym.fyman.idv.tw/blog/archives/6</guid>
		<description><![CDATA[下載了新版 MySQL 4.1.x 及 phpMyAdmin 安裝在 XP 系統上測試，結果發現 phpMyAdmin 無法正常登入，出現如下錯誤訊息：
#1251 - Client does not support authentication protocol requested by server; consider upgrading MySQL client
於是在 MySQL 官網找到解決方法，照做之後就OK囉！有此問題的可以參考看看。
(1) 在開始 → 執行輸入"CMD"進入命令列模式。
(2) 輸入 "MySQL 路徑\bin\mysql -h localhost -u root -p"。(要重設root密碼)
(3) 接著會出現 Enter Password：輸入安裝MySQL打的密碼。
(4) mysql&#62;提示符號鍵入：SET PASSWORD FOR
(5) 再輸入：'root'@'localhost' = OLD_PASSWORD('新密碼');
(6) 完成，現在就可以登入 phpMyAdmin 囉！
補充：
1.問題原因為 MySQL 4.1 以上使用新的密碼驗證機制，而 PHP4 尚未支援。
2.只要是 MySQL [...]]]></description>
			<content:encoded><![CDATA[<p>下載了新版 MySQL 4.1.x 及 phpMyAdmin 安裝在 XP 系統上測試，結果發現 phpMyAdmin 無法正常登入，出現如下錯誤訊息：</p>
<p><em>#1251 - Client does not support authentication protocol requested by server; consider upgrading MySQL client</em></p>
<p>於是在 MySQL 官網找到解決方法，照做之後就OK囉！有此問題的可以參考看看。</p>
<p>(1) 在開始 → 執行輸入"CMD"進入命令列模式。<br />
(2) 輸入 "MySQL 路徑\bin\mysql -h localhost -u root -p"。(要重設root密碼)<br />
(3) 接著會出現 Enter Password：輸入安裝MySQL打的密碼。<br />
(4) mysql&gt;提示符號鍵入：SET PASSWORD FOR<br />
(5) 再輸入：'root'@'localhost' = OLD_PASSWORD('新密碼');<br />
(6) 完成，現在就可以登入 phpMyAdmin 囉！</p>
<p>補充：<br />
1.問題原因為 MySQL 4.1 以上使用新的密碼驗證機制，而 PHP4 尚未支援。<br />
2.只要是 MySQL 4.1.x 及以上的版本無法連接都可照此方法試試。<br />
3.升級成 PHP5 則無此問題。</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.linym.net/archives/6/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
