<?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>perlとMysqlでCGI &#38; サーバ管理 漏れ的メモ &#187; MySQL</title>
	<atom:link href="http://perl.no-tubo.net/category/mysql/feed/" rel="self" type="application/rss+xml" />
	<link>http://perl.no-tubo.net</link>
	<description>perl＆MySQLでCGIプログラミング。ウェブ運営の小技。鯖管メモもちょっとだけ。</description>
	<lastBuildDate>Mon, 23 Aug 2010 04:41:59 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>ja</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>MySQL で年月日等の日付別に集計する</title>
		<link>http://perl.no-tubo.net/2010/06/04/mysql-%e3%81%a7%e5%b9%b4%e6%9c%88%e6%97%a5%e7%ad%89%e3%81%ae%e6%97%a5%e4%bb%98%e5%88%a5%e3%81%ab%e9%9b%86%e8%a8%88%e3%81%99%e3%82%8b/</link>
		<comments>http://perl.no-tubo.net/2010/06/04/mysql-%e3%81%a7%e5%b9%b4%e6%9c%88%e6%97%a5%e7%ad%89%e3%81%ae%e6%97%a5%e4%bb%98%e5%88%a5%e3%81%ab%e9%9b%86%e8%a8%88%e3%81%99%e3%82%8b/#comments</comments>
		<pubDate>Fri, 04 Jun 2010 11:21:40 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[SQL構文]]></category>

		<guid isPermaLink="false">http://perl.no-tubo.net/?p=535</guid>
		<description><![CDATA[いまさら月次集計や年毎の集計など


集計をする際は、主にGROUP BYを多く用いる。
YEAR(), MONTH(), DAY(), DAYNAME(), EXTRACT()が便利。


WHERE で条件しぼるんじ [...]]]></description>
			<content:encoded><![CDATA[<p>いまさら月次集計や年毎の集計など</p>
<ul>
<blockquote>
<li>集計をする際は、主にGROUP BYを多く用いる。</li>
<li>YEAR(), MONTH(), DAY(), DAYNAME(), EXTRACT()が便利。</li>
</blockquote>
</ul>
<p>WHERE で条件しぼるんじゃないらしい（ｦｲ）</p>
<p>2010-05 2010-06 等で年月別の集計なら、</p>
<pre>SELECT EXTRACT(YEAR_MONTH FROM `datetime`) as 'year_month' ,
SUM(`price`) as price
FROM `hoge_table`
GROUP BY EXTRACT(YEAR_MONTH FROM `datetime `);</pre>
<p>とか。（参照ページの例文に間違い有り as が抜けているのと エイリアスとして year_month と言う文字列を指定する場合はクォートで囲まないとエラーになる）</p>
<pre>year_month	price
200811	34259
200812	49258
200901	67447</pre>
<p>結果はこんな感じになる。</p>
<p>参照：<a href="http://www.flatz.jp/archives/75">MySQLの知っていると便利な構文（その2）</a></p>
]]></content:encoded>
			<wfw:commentRss>http://perl.no-tubo.net/2010/06/04/mysql-%e3%81%a7%e5%b9%b4%e6%9c%88%e6%97%a5%e7%ad%89%e3%81%ae%e6%97%a5%e4%bb%98%e5%88%a5%e3%81%ab%e9%9b%86%e8%a8%88%e3%81%99%e3%82%8b/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MySQLのINT等の整数型カラム(UNSIGNED)から減算する時に注意</title>
		<link>http://perl.no-tubo.net/2009/10/29/mysql%e3%81%aeint%e7%ad%89%e3%81%ae%e6%95%b4%e6%95%b0%e5%9e%8b%e3%82%ab%e3%83%a9%e3%83%a0unsigned%e3%81%8b%e3%82%89%e6%b8%9b%e7%ae%97%e3%81%99%e3%82%8b%e6%99%82%e3%81%ab%e6%b3%a8%e6%84%8f/</link>
		<comments>http://perl.no-tubo.net/2009/10/29/mysql%e3%81%aeint%e7%ad%89%e3%81%ae%e6%95%b4%e6%95%b0%e5%9e%8b%e3%82%ab%e3%83%a9%e3%83%a0unsigned%e3%81%8b%e3%82%89%e6%b8%9b%e7%ae%97%e3%81%99%e3%82%8b%e6%99%82%e3%81%ab%e6%b3%a8%e6%84%8f/#comments</comments>
		<pubDate>Thu, 29 Oct 2009 10:53:17 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[MySQL]]></category>

		<guid isPermaLink="false">http://perl.no-tubo.net/?p=275</guid>
		<description><![CDATA[MySQL4.xでは大丈夫だったけど、MySQL5.xに移行してから起こった出来事。
整数型カラムをUNSIGNEDして利用している時、負の数にならないのをいい事に0から減算して負の数の場合は0と自動で処理してくるものだ [...]]]></description>
			<content:encoded><![CDATA[<h4>MySQL4.xでは大丈夫だったけど、MySQL5.xに移行してから起こった出来事。</h4>
<p>整数型カラムをUNSIGNEDして利用している時、負の数にならないのをいい事に0から減算して負の数の場合は0と自動で処理してくるものだと思っていた。（MySQL4.x時にはそのように処理されていた。）</p>
<p>本当はプログラム側で処理するべきなのかもしれないけれど、楽してそのようなスクリプトを書いていた。</p>
<p>で、先日MySQL5.xの環境に移行したらデータがおかしくなっていた。</p>
<p>とてつもなく大きな数字となっており？？？状態。</p>
<p>どうやら、UNSIGNEDしているカラムが0で、そこから1を引くと4294967295のような値になってしまうようだ。</p>
<p>これを回避するにはコマンドラインオプションで</p>
<blockquote><p>&#8211;sql-mode=NO_UNSIGNED_SUBTRACTION</p></blockquote>
<p>とするか、SQL発行時に</p>
<blockquote><p>SET SQL_MODE=&#8217;NO_UNSIGNED_SUBTRACTION&#8217;;</p></blockquote>
<p>とすると大丈夫のようだ。</p>
<p>参考： <a href="http://mlog.euqset.org/archives/ml@mysql.gr.jp/14844.html">http://mlog.euqset.org/archives/ml@mysql.gr.jp/14844.html</a></p>
]]></content:encoded>
			<wfw:commentRss>http://perl.no-tubo.net/2009/10/29/mysql%e3%81%aeint%e7%ad%89%e3%81%ae%e6%95%b4%e6%95%b0%e5%9e%8b%e3%82%ab%e3%83%a9%e3%83%a0unsigned%e3%81%8b%e3%82%89%e6%b8%9b%e7%ae%97%e3%81%99%e3%82%8b%e6%99%82%e3%81%ab%e6%b3%a8%e6%84%8f/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CentOS5.3 PostfixをMySQL対応にする</title>
		<link>http://perl.no-tubo.net/2009/10/02/centos5-3-postfix%e3%82%92mysql%e5%af%be%e5%bf%9c%e3%81%ab%e3%81%99%e3%82%8b/</link>
		<comments>http://perl.no-tubo.net/2009/10/02/centos5-3-postfix%e3%82%92mysql%e5%af%be%e5%bf%9c%e3%81%ab%e3%81%99%e3%82%8b/#comments</comments>
		<pubDate>Fri, 02 Oct 2009 09:40:04 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[CentOS5.x]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[メールサーバ]]></category>

		<guid isPermaLink="false">http://pet.no-tubo.net/?p=182</guid>
		<description><![CDATA[yumでインストールされていたらアンインストール
yum erase postfix
ダウンロード
最新版の確認（/5.x/centosplus/SRPMS/より）
rpm -ivh http://ftp.riken.j [...]]]></description>
			<content:encoded><![CDATA[<p>yumでインストールされていたらアンインストール</p>
<pre>yum erase postfix</pre>
<h4>ダウンロード</h4>
<p><a href="http://ftp.riken.jp/Linux/centos/">最新版の確認</a>（/5.x/centosplus/SRPMS/より）</p>
<pre>rpm -ivh http://ftp.riken.jp/Linux/centos/5.4/centosplus/SRPMS/postfix-2.3.3-2.1.centos.mysql_pgsql.src.rpm</pre>
<h4>コンパイル前の下準備</h4>
<p>Postfix をMySQL対応にするためpostfix.specを編集。</p>
<pre>cd /usr/src/redhat/SPECS/
vi postfix.spec
..
%define MYSQL 1　←確認（0なら1に修正）
..</pre>
<h4>コンパイル</h4>
<p>srpmからrpmを作成する。</p>
<pre>rpmbuild -bb postfix.spec</pre>
<h4>インストール</h4>
<p>出来上がったRPMをインストールする。</p>
<pre>cd /usr/src/redhat/RPMS/i386/
rpm -Uvh postfix-2.3.3-2.1.centos.mysql_pgsql.i386.rpm</pre>
<h4>yumの自動アップデートから外す</h4>
<p>yum update で postfix* なパッケージがアップデートされなくなる。</p>
<p>これをしないとyumの自動アップデート時にMySQL非対応に戻ってしまう。</p>
<pre>vi /etc/yum.conf
<span style="color: #ff0000;"> exclude=postfix*　←最終業に追記</span></pre>
<p>↑手動でもやりましたけど<br />
<a href="http://perl.no-tubo.net/2010/03/08/postfixをyumでアップデートしてしまった-orz/">Postfixをyumでアップデートしてしまった orz&#8230;</a></p>
]]></content:encoded>
			<wfw:commentRss>http://perl.no-tubo.net/2009/10/02/centos5-3-postfix%e3%82%92mysql%e5%af%be%e5%bf%9c%e3%81%ab%e3%81%99%e3%82%8b/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>MySQL DATETIME型へのINDEX注意点</title>
		<link>http://perl.no-tubo.net/2009/05/18/mysql-datetime%e5%9e%8b%e3%81%b8%e3%81%aeindex%e6%b3%a8%e6%84%8f%e7%82%b9/</link>
		<comments>http://perl.no-tubo.net/2009/05/18/mysql-datetime%e5%9e%8b%e3%81%b8%e3%81%aeindex%e6%b3%a8%e6%84%8f%e7%82%b9/#comments</comments>
		<pubDate>Mon, 18 May 2009 08:15:34 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[SQL構文]]></category>
		<category><![CDATA[MySQL]]></category>

		<guid isPermaLink="false">http://pet.no-tubo.net/?p=126</guid>
		<description><![CDATA[MySQLのDATETIME型へインデックスをつける場合注意が必要。
例えばこんなSQLではインデックスが使用されない。
SELECT * FROM  `table` WHERE  `datetime` LIKE  '2 [...]]]></description>
			<content:encoded><![CDATA[<p>MySQLのDATETIME型へインデックスをつける場合注意が必要。<br />
例えばこんなSQLではインデックスが使用されない。</p>
<pre>SELECT * FROM  `table` WHERE  `datetime` LIKE  '2009-05-17%'</pre >
検索結果は2009-05-17分全てが抽出されるが、フルスキャンがかかる。
この場合、以下のようなSQLが良い。
<pre>SELECT * FROM  `table`
WHERE  `date_time` BETWEEN '2009-05-17' AND '2009-05-17' + INTERVAL 1 DAY</pre>
<p>実行時間計測の例<br />
行数：13,776行<br />
データ：2,935KB<br />
インデックス：datetime</p>
<hr />
<pre>SELECT SUM(  `col` ) FROM  `table`
WHERE  `datetime` LIKE  '2009-05-17%'</pre>
<p>フルスキャン<br />
実行時間：0.0235 秒</p>
<hr />
<pre>SELECT SUM(  `col` ) FROM  `table`
WHERE  DATE(datetime) =  '2009-05-17'</pre>
<p>フルスキャン<br />
実行時間：0.0383 秒</p>
<hr />
<pre>SELECT SUM(  `col` ) FROM  `table`
WHERE `date_time` BETWEEN  '2009-05-17' AND  '2009-05-17' + INTERVAL 1 DAY</pre>
<p>インデックス使用<br />
実行時間：0.0009 秒</p>
]]></content:encoded>
			<wfw:commentRss>http://perl.no-tubo.net/2009/05/18/mysql-datetime%e5%9e%8b%e3%81%b8%e3%81%aeindex%e6%b3%a8%e6%84%8f%e7%82%b9/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>DBIでMysql を使う時の文字コード指定</title>
		<link>http://perl.no-tubo.net/2009/04/11/dbi%e3%81%a7mysql-%e3%82%92%e4%bd%bf%e3%81%86%e6%99%82%e3%81%ae%e6%96%87%e5%ad%97%e3%82%b3%e3%83%bc%e3%83%89%e6%8c%87%e5%ae%9a/</link>
		<comments>http://perl.no-tubo.net/2009/04/11/dbi%e3%81%a7mysql-%e3%82%92%e4%bd%bf%e3%81%86%e6%99%82%e3%81%ae%e6%96%87%e5%ad%97%e3%82%b3%e3%83%bc%e3%83%89%e6%8c%87%e5%ae%9a/#comments</comments>
		<pubDate>Sat, 11 Apr 2009 08:23:18 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[DBI(DBD::mysql)]]></category>
		<category><![CDATA[MySQL]]></category>

		<guid isPermaLink="false">http://pet.no-tubo.net/?p=132</guid>
		<description><![CDATA[接続時

my $dbh = DBI-&#62;connect(&#8216;DBI:mysql:database=sandbox;host=localhost;mysql_read_default_file=/etc/m [...]]]></description>
			<content:encoded><![CDATA[<p style="margin-top: 10px; margin-right: 12px; margin-bottom: 10px; margin-left: 12px; font-size: 13px; font-weight: normal; font-style: normal; font-family: Verdana, 'ヒラギノ角ゴ Pro W3', 'ＭＳ ゴシック', Osaka‐等幅; text-align: left; color: #444444; line-height: 1.4; padding: 0px;">接続時</p>
<blockquote>
<p style="margin-top: 10px; margin-right: 12px; margin-bottom: 10px; margin-left: 12px; font-size: 13px; font-weight: normal; font-style: normal; font-family: Verdana, 'ヒラギノ角ゴ Pro W3', 'ＭＳ ゴシック', Osaka‐等幅; text-align: left; color: #444444; line-height: 1.4; padding: 0px;">my $dbh = DBI-&gt;connect(<br style="font-size: 13px; font-weight: normal; font-style: normal; font-family: Verdana, 'ヒラギノ角ゴ Pro W3', 'ＭＳ ゴシック', Osaka‐等幅; text-align: left; color: #111111; padding: 0px; margin: 0px;" />&#8216;DBI:mysql:database=sandbox;host=localhost;mysql_read_default_file=/etc/mysql/my.cnf&#8217;,<br style="font-size: 13px; font-weight: normal; font-style: normal; font-family: Verdana, 'ヒラギノ角ゴ Pro W3', 'ＭＳ ゴシック', Osaka‐等幅; text-align: left; color: #111111; padding: 0px; margin: 0px;" />qw/id password/,<br style="font-size: 13px; font-weight: normal; font-style: normal; font-family: Verdana, 'ヒラギノ角ゴ Pro W3', 'ＭＳ ゴシック', Osaka‐等幅; text-align: left; color: #111111; padding: 0px; margin: 0px;" />);</p>
</blockquote>
<p style="margin-top: 10px; margin-right: 12px; margin-bottom: 10px; margin-left: 12px; font-size: 13px; font-weight: normal; font-style: normal; font-family: Verdana, 'ヒラギノ角ゴ Pro W3', 'ＭＳ ゴシック', Osaka‐等幅; text-align: left; color: #444444; line-height: 1.4; padding: 0px;">または接続後に<br style="font-size: 13px; font-weight: normal; font-style: normal; font-family: Verdana, 'ヒラギノ角ゴ Pro W3', 'ＭＳ ゴシック', Osaka‐等幅; text-align: left; color: #111111; padding: 0px; margin: 0px;" /></p>
<blockquote>
<p style="margin-top: 10px; margin-right: 12px; margin-bottom: 10px; margin-left: 12px; font-size: 13px; font-weight: normal; font-style: normal; font-family: Verdana, 'ヒラギノ角ゴ Pro W3', 'ＭＳ ゴシック', Osaka‐等幅; text-align: left; color: #444444; line-height: 1.4; padding: 0px;">$dbh-&gt;{ mysql_enable_utf8 } = 1;</p>
</blockquote>
<p style="margin-top: 10px; margin-right: 12px; margin-bottom: 10px; margin-left: 12px; font-size: 13px; font-weight: normal; font-style: normal; font-family: Verdana, 'ヒラギノ角ゴ Pro W3', 'ＭＳ ゴシック', Osaka‐等幅; text-align: left; color: #444444; line-height: 1.4; padding: 0px;"><br style="font-size: 13px; font-weight: normal; font-style: normal; font-family: Verdana, 'ヒラギノ角ゴ Pro W3', 'ＭＳ ゴシック', Osaka‐等幅; text-align: left; color: #111111; padding: 0px; margin: 0px;" />この辺の記事<br style="font-size: 13px; font-weight: normal; font-style: normal; font-family: Verdana, 'ヒラギノ角ゴ Pro W3', 'ＭＳ ゴシック', Osaka‐等幅; text-align: left; color: #111111; padding: 0px; margin: 0px;" /><a style="font-size: 13px; font-weight: normal; font-style: normal; font-family: Verdana, 'ヒラギノ角ゴ Pro W3', 'ＭＳ ゴシック', Osaka‐等幅; text-align: left; color: #333333; text-decoration: underline; padding: 0px; margin: 0px;" href="http://www.geminium.com/chiba_blog/2009/02/" target="_blank">http://www.geminium.com/chiba_blog/2009/02/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://perl.no-tubo.net/2009/04/11/dbi%e3%81%a7mysql-%e3%82%92%e4%bd%bf%e3%81%86%e6%99%82%e3%81%ae%e6%96%87%e5%ad%97%e3%82%b3%e3%83%bc%e3%83%89%e6%8c%87%e5%ae%9a/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PhpMyAdminの導入</title>
		<link>http://perl.no-tubo.net/2009/02/17/phpmyadmin%e3%81%ae%e5%b0%8e%e5%85%a5/</link>
		<comments>http://perl.no-tubo.net/2009/02/17/phpmyadmin%e3%81%ae%e5%b0%8e%e5%85%a5/#comments</comments>
		<pubDate>Tue, 17 Feb 2009 07:53:13 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[phpmyadmin]]></category>

		<guid isPermaLink="false">http://pet.no-tubo.net/?p=112</guid>
		<description><![CDATA[phpmyadminインストール
yum install phpmyadmin
/usr/share/phpmyadmin にインストールされる。
/usr/share/phpmyadmin/config.inc.php [...]]]></description>
			<content:encoded><![CDATA[<p>phpmyadminインストール</p>
<blockquote><p>yum install phpmyadmin</p></blockquote>
<p>/usr/share/phpmyadmin にインストールされる。<br />
/usr/share/phpmyadmin/config.inc.phpを編集<br />
$cfg['blowfish_secret']を設定。</p>
<blockquote><p>/*<br />
* This is needed for cookie based authentication to encrypt password in<br />
* cookie<br />
*/<br />
$cfg['blowfish_secret'] = &#8216;*************&#8217;; /* YOU MUST FILL IN THIS FOR COOKIE AUTH! */</p></blockquote>
<p>「mcrypt 拡張をロードできません。PHP の設定を確認してください」というエラーが出たのでインストール。</p>
<blockquote><p>yum -y install php-mbstring<br />
yum -y install php-mcrypt</p></blockquote>
<p>phpでマルチバイト処理をするには「php-mbstring」が必要.<br />
CentOS5だと上記でよいが、CentOS4だとインストールされない。</p>
<p>CentOS4での手順<br />
１．mcryptを組み込むのに必要なlibmcryptをrpmforgeからインストールします。</p>
<blockquote><p># yum -y &#8211;enablerepo=rpmforge install libmcrypt-devel</p></blockquote>
<p>２．php用のmcrypt拡張モジュールをPHPRPMsよりダウンロードします。</p>
<blockquote><p># cd /usr/src/redhat/RPMS/i386/<br />
# wget http://jaist.dl.sourceforge.net/sourceforge/phprpms/php-mcrypt-4.3.9-3.2.1.i386.rpm</p></blockquote>
<p>最新版は <a style="font-size: 13px; font-weight: normal; font-style: normal; font-family: Verdana, 'ヒラギノ角ゴ Pro W3', 'ＭＳ ゴシック', Osaka‐等幅; text-align: left; color: #ff6699; text-decoration: underline; padding: 0px; margin: 0px;" href="http://phprpms.sourceforge.net/mcrypt" target="_blank">http://phprpms.sourceforge.net/mcrypt</a> で確認して下さい。<br />
CentOSはRHEL互換なのでRHEL4の物を落としました。<br />
X86_64で無いならばi386で問題ありません。</p>
<p>３．ダウンロードしたrpmをインストールします。</p>
<blockquote><p># rpm -Uvh php-mcrypt-4.3.9-3.2.1.i386.rpm</p></blockquote>
<p>参考： <a style="font-size: 13px; font-weight: normal; font-style: normal; font-family: Verdana, 'ヒラギノ角ゴ Pro W3', 'ＭＳ ゴシック', Osaka‐等幅; text-align: left; color: #333333; text-decoration: underline; padding: 0px; margin: 0px;" href="http://centossrv.com/bbshtml/webpatio/364.shtml" target="_blank">http://centossrv.com/bbshtml/webpatio/364.shtml</a></p>
<p>・・・が、<a style="font-size: 13px; font-weight: normal; font-style: normal; font-family: Verdana, 'ヒラギノ角ゴ Pro W3', 'ＭＳ ゴシック', Osaka‐等幅; text-align: left; color: #333333; text-decoration: underline; padding: 0px; margin: 0px;" href="http://phprpms.sourceforge.net/mcrypt" target="_blank">http://phprpms.sourceforge.net/mcrypt</a>は現在無い&#8230;。<br />
しょうがないので、<a style="font-size: 13px; font-weight: normal; font-style: normal; font-family: Verdana, 'ヒラギノ角ゴ Pro W3', 'ＭＳ ゴシック', Osaka‐等幅; text-align: left; color: #ff6699; text-decoration: underline; padding: 0px; margin: 0px;" href="http://rpm.pbone.net/" target="_blank">http://rpm.pbone.net/</a>で探す。<br />
キーワード「php-mcrypt」CentOS 4 とRedHat EL 4 にチェックを入れサーチ。</p>
<blockquote><p># php -v</p></blockquote>
<p>でPHP 4.3.9dだったので、<br />
RedHat EL 4 ftp.sourceforge.net/pub/sourceforge/p/project/ph/phprpms/RHEL4 PHP RPMs/4.3.9-3.2/php-mcrypt-4.3.9-3.2.1.i386.rpm<br />
<a style="font-size: 13px; font-weight: normal; font-style: normal; font-family: Verdana, 'ヒラギノ角ゴ Pro W3', 'ＭＳ ゴシック', Osaka‐等幅; text-align: left; color: #333333; text-decoration: underline; padding: 0px; margin: 0px;" href="http://rpm.pbone.net/index.php3/stat/4/idpl/12753489/com/php-mcrypt-4.3.9-3.2.1.i386.rpm.html" target="_blank">http://rpm.pbone.net/index.php3/stat/4/idpl/12753489/com/php-mcrypt-4.3.9-3.2.1.i386.rpm.html</a></p>
<p>が、見つかったのでこれを使ってみる。</p>
<blockquote><p># wget ftp://ftp.pbone.net/mirror/ftp.sourceforge.net/pub/sourceforge/p/project/ph/phprpms/RHEL4%20PHP%20RPMs/4.3.9-3.2/php-mcrypt-4.3.9-3.2.1.i386.rpm</p>
<p>rpm -ivh php-mcrypt-4.3.9-3.2.1.i386.rpm</p></blockquote>
<p>成功した。</p>
<p>Apacheの設定。<br />
/etc/httpd/conf.d/phpmyadmin.conf が作成されるので適時修正。<br />
Apache再起動。</p>
]]></content:encoded>
			<wfw:commentRss>http://perl.no-tubo.net/2009/02/17/phpmyadmin%e3%81%ae%e5%b0%8e%e5%85%a5/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MySQL(Tritonn)を複数インストール</title>
		<link>http://perl.no-tubo.net/2009/02/17/mysqltritonn%e3%82%92%e8%a4%87%e6%95%b0%e3%82%a4%e3%83%b3%e3%82%b9%e3%83%88%e3%83%bc%e3%83%ab/</link>
		<comments>http://perl.no-tubo.net/2009/02/17/mysqltritonn%e3%82%92%e8%a4%87%e6%95%b0%e3%82%a4%e3%83%b3%e3%82%b9%e3%83%88%e3%83%bc%e3%83%ab/#comments</comments>
		<pubDate>Tue, 17 Feb 2009 07:50:53 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Toritonn]]></category>
		<category><![CDATA[サーバ管理]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Ttitonn]]></category>

		<guid isPermaLink="false">http://pet.no-tubo.net/?p=100</guid>
		<description><![CDATA[MySQL4.12が稼働しているサーバにMySQL5.0.67(Ttitonn)をインストールする（MySQL4.12はYUMでインストール済）
my.cnf (MySQL4.12)
[mysqld]
datadir=/ [...]]]></description>
			<content:encoded><![CDATA[<p>MySQL4.12が稼働しているサーバにMySQL5.0.67(Ttitonn)をインストールする<br style="font-size: 13px; font-weight: normal; font-style: normal; font-family: Verdana, 'ヒラギノ角ゴ Pro W3', 'ＭＳ ゴシック', Osaka‐等幅; text-align: left; color: #111111; padding: 0px; margin: 0px;" />（MySQL4.12はYUMでインストール済）</p>
<p>my.cnf (MySQL4.12)</p>
<pre>[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
# Default to using old password format for compatibility with mysql 3.x
# clients (those using the mysqlclient10 compatibility package).
old_passwords=1

[mysql.server]
user=mysql
basedir=/var/lib

[mysqld_safe]
err-log=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid</pre>
<p>１）mecabのインストール</p>
<p><a href="?p=84">mecabのインストール</a></p>
<p>２）sennaのインストール</p>
<p><a href="?p=81">senna 1.1.4のインストール</a></p>
<p>３）インストールするのはTritonn（MySQL5.0.67）<br />
/usr/local/mysql5にインストールする<br />
※mecab sennaはインストール済み</p>
<blockquote><p>wget http://iij.dl.sourceforge.jp/tritonn/36449/tritonn-1.0.12-mysql-5.0.67.tar.gz<br />
tar xzf tritonn-1.0.12-mysql-5.0.67.tar.gz<br />
cd tritonn-1.0.12-mysql-5.0.67<br />
su&#8211;<br />
./configure &#8211;prefix=/usr/local/mysql5 &#8211;localstatedir=/usr/local/mysql5/data &#8211;with-unix-socket-path=/usr/local/mysql5/data/mysql5.sock &#8211;with-tcp-port=3307 &#8211;with-charset=utf8 &#8211;with-extra-charsets=all &#8211;with-mysqld-user=mysql &#8211;with-senna &#8211;with-mecab<br />
make<br />
mkdir /usr/local/mysql5<br />
make install<br />
cd /usr/local/mysql5<br />
mkdir /usr/local/mysql5/data<br />
chown -R mysql:mysql /usr/local/mysql5<br />
su mysql<br />
./bin/mysql_install_db &#8211;datadir=/usr/local/mysql5/data</p></blockquote>
<p>複数インストール<span style="text-decoration: underline;"><strong>しない</strong></span>場合のconfigureオプションはこんな感じ</p>
<blockquote><p>CC=&#8217;gcc&#8217;  CFLAGS=&#8217;-g&#8217;  CXX=&#8217;gcc&#8217;  CXXFLAGS=&#8217;-g&#8217;  LDFLAGS=&#8221;  ASFLAGS=&#8221; \<br />
./configure \<br />
&#8216;&#8211;prefix=/usr/local/mysql&#8217; \<br />
&#8216;&#8211;localstatedir=/usr/local/mysql/data&#8217; \<br />
&#8216;&#8211;libexecdir=/usr/local/mysql/bin&#8217; \<br />
&#8216;&#8211;with-comment=MySQL Community Server (GPL)&#8217; \<br />
&#8216;&#8211;with-server-suffix=&#8217; \<br />
&#8216;&#8211;enable-thread-safe-client&#8217; \<br />
&#8216;&#8211;enable-local-infile&#8217; \<br />
&#8216;&#8211;enable-assembler&#8217; \<br />
&#8216;&#8211;with-pic&#8217; \<br />
&#8216;&#8211;with-fast-mutexes&#8217; \<br />
&#8216;&#8211;with-client-ldflags=-static&#8217; \<br />
&#8216;&#8211;with-mysqld-ldflags=-static&#8217; \<br />
&#8216;&#8211;with-zlib-dir=bundled&#8217; \<br />
&#8216;&#8211;with-big-tables&#8217; \<br />
&#8216;&#8211;with-yassl&#8217; \<br />
&#8216;&#8211;with-readline&#8217; \<br />
&#8216;&#8211;with-archive-storage-engine&#8217; \<br />
&#8216;&#8211;with-blackhole-storage-engine&#8217; \<br />
&#8216;&#8211;with-ndbcluster&#8217; \<br />
&#8216;&#8211;with-csv-storage-engine&#8217; \<br />
&#8216;&#8211;with-example-storage-engine&#8217; \<br />
&#8216;&#8211;with-federated-storage-engine&#8217; \<br />
&#8216;&#8211;with-innodb&#8217; \<br />
&#8216;&#8211;with-charset=utf8&#8242; \<br />
&#8216;&#8211;with-extra-charsets=all&#8217; \<br />
&#8216;&#8211;with-senna&#8217; &#8216;&#8211;with-mecab&#8217;</p></blockquote>
<p>configure時に以下のエラーが出た時の対処</p>
<blockquote><p>checking for termcap functions library&#8230; configure: error: No curses/termcap library found</p></blockquote>
<p>curses/termcapのライブラリが無いらしい</p>
<blockquote><p>yum install ncurses-devel</p></blockquote>
<p>４）データベースの初期化</p>
<blockquote><p>/usr/local/mysql/bin/mysql_install_db &#8211;user=mysql</p></blockquote>
<p>５）初期ユーザー作成<br />
MySQL起動後に初期ユーザーrootでログイン。<br />
このrootはローカルから接続出来るユーザー。</p>
<p>初期ユーザーを全て削除し、新規ユーザーを作成する。</p>
<blockquote><p>./bin/mysqld_safe &#8211;defaults-file=/etc/my5.cnf &#8211;pid-file=/var/run/mysqld/mysqld5.pid &amp;<br />
/usr/local/mysql5/bin/mysql &#8211;user=root</p></blockquote>
<p>MySQLに接続後、既存ユーザー削除</p>
<blockquote><p>/usr/local/mysql5/bin/mysql &#8211;user=root<br />
mysql&gt; TRUNCATE TABLE mysql.user;</p>
<p>mysql&gt; FLUSH PRIVILEGES;</p></blockquote>
<p>管理ユーザー作成( 管理ユーザー：root パスワード：password)</p>
<blockquote><p>mysql&gt; GRANT ALL PRIVILEGES ON *.* TO &#8216;root&#8217;@'localhost&#8217; IDENTIFIED BY &#8216;password&#8217; WITH GRANT OPTION;</p></blockquote>
<p>補足：シンボリックリンクを貼って「mysql5」でアクセスする</p>
<blockquote><p>su &#8211;<br />
ln -s /usr/local/mysql5/bin/mysql /usr/bin/mysql5</p></blockquote>
<p>$ mysql5 &#8211;user=***** &#8211;password=************<br />
でアクセス可能。</p>
]]></content:encoded>
			<wfw:commentRss>http://perl.no-tubo.net/2009/02/17/mysqltritonn%e3%82%92%e8%a4%87%e6%95%b0%e3%82%a4%e3%83%b3%e3%82%b9%e3%83%88%e3%83%bc%e3%83%ab/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>連続で大量のデータをINSERTする実験</title>
		<link>http://perl.no-tubo.net/2009/02/06/%e9%80%a3%e7%b6%9a%e3%81%a7%e5%a4%a7%e9%87%8f%e3%81%ae%e3%83%87%e3%83%bc%e3%82%bf%e3%82%92insert%e3%81%99%e3%82%8b%e5%ae%9f%e9%a8%93/</link>
		<comments>http://perl.no-tubo.net/2009/02/06/%e9%80%a3%e7%b6%9a%e3%81%a7%e5%a4%a7%e9%87%8f%e3%81%ae%e3%83%87%e3%83%bc%e3%82%bf%e3%82%92insert%e3%81%99%e3%82%8b%e5%ae%9f%e9%a8%93/#comments</comments>
		<pubDate>Fri, 06 Feb 2009 07:24:53 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[DBI(DBD::mysql)]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[webプログラミング]]></category>
		<category><![CDATA[perl]]></category>

		<guid isPermaLink="false">http://pet.no-tubo.net/?p=89</guid>
		<description><![CDATA[PERLでMySQLにデータを挿入する実験。
実験スクリプト
INSERT を100万回繰り返す。
for(1..1000000){
$sql = &#60;&#60;"EOM";
INSERT INTO `table_na [...]]]></description>
			<content:encoded><![CDATA[<p>PERLでMySQLにデータを挿入する実験。</p>
<p>実験スクリプト</p>
<p>INSERT を100万回繰り返す。</p>
<pre>for(1..1000000){
$sql = &lt;&lt;"EOM";
INSERT INTO `table_name`
(`col1`,`col2`,`col3`,`col4`) VALUES ('10','11','12','13');
EOM

$sth = $dbh-&gt;do($sql)|| die $dbh-&gt;errstr;
}</pre>
<p>結果：途中でサーバエラー</p>
<blockquote><p>Server error!</p>
<p>The server encountered an internal error and was unable to complete your request.</p>
<p>Error message:</p>
<p>Premature end of script headers: xxxx.cgi</p>
<p>If you think this is a server error, please contact the webmaster.</p>
<p>Error 500</p></blockquote>
<p>httpd/error_logの出力：</p>
<pre>[Fri Feb 06 20:04:00 2009] [error] [client xx.xxx.xxx.xxx] Premature end of script headers: sql.cgi</pre>
<p>挿入されたデータ：約83万行</p>
<p>httpd.confの設定が、TimeOut 60によるエラーか？</p>
]]></content:encoded>
			<wfw:commentRss>http://perl.no-tubo.net/2009/02/06/%e9%80%a3%e7%b6%9a%e3%81%a7%e5%a4%a7%e9%87%8f%e3%81%ae%e3%83%87%e3%83%bc%e3%82%bf%e3%82%92insert%e3%81%99%e3%82%8b%e5%ae%9f%e9%a8%93/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>DBI &amp; MySQLでカウントする</title>
		<link>http://perl.no-tubo.net/2008/10/21/dbi-mysql%e3%81%a7%e3%82%ab%e3%82%a6%e3%83%b3%e3%83%88%e3%81%99%e3%82%8b/</link>
		<comments>http://perl.no-tubo.net/2008/10/21/dbi-mysql%e3%81%a7%e3%82%ab%e3%82%a6%e3%83%b3%e3%83%88%e3%81%99%e3%82%8b/#comments</comments>
		<pubDate>Tue, 21 Oct 2008 08:08:53 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[DBI(DBD::mysql)]]></category>
		<category><![CDATA[perl]]></category>
		<category><![CDATA[webプログラミング]]></category>

		<guid isPermaLink="false">http://pet.no-tubo.net/?p=61</guid>
		<description><![CDATA[$COUNT = $dbh-&#62;selectrow_array("SELECT COUNT(*) FROM  `テーブル名` WHERE `カラム` = '条件'");
]]></description>
			<content:encoded><![CDATA[<pre>$COUNT = $dbh-&gt;selectrow_array("SELECT COUNT(*) FROM  `テーブル名` WHERE `カラム` = '条件'");</pre>
]]></content:encoded>
			<wfw:commentRss>http://perl.no-tubo.net/2008/10/21/dbi-mysql%e3%81%a7%e3%82%ab%e3%82%a6%e3%83%b3%e3%83%88%e3%81%99%e3%82%8b/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>自分が追加した最新のauto_increment番号を取得する</title>
		<link>http://perl.no-tubo.net/2008/10/03/%e8%87%aa%e5%88%86%e3%81%8c%e8%bf%bd%e5%8a%a0%e3%81%97%e3%81%9f%e6%9c%80%e6%96%b0%e3%81%aeauto_increment%e7%95%aa%e5%8f%b7%e3%82%92%e5%8f%96%e5%be%97%e3%81%99%e3%82%8b-2/</link>
		<comments>http://perl.no-tubo.net/2008/10/03/%e8%87%aa%e5%88%86%e3%81%8c%e8%bf%bd%e5%8a%a0%e3%81%97%e3%81%9f%e6%9c%80%e6%96%b0%e3%81%aeauto_increment%e7%95%aa%e5%8f%b7%e3%82%92%e5%8f%96%e5%be%97%e3%81%99%e3%82%8b-2/#comments</comments>
		<pubDate>Fri, 03 Oct 2008 06:16:41 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[DBI(DBD::mysql)]]></category>
		<category><![CDATA[perl]]></category>

		<guid isPermaLink="false">http://pet.no-tubo.net/?p=65</guid>
		<description><![CDATA[$sql = "INSERT INTO `db_01` ( data1, data2 ) VALUES ( $data1, $data2 )";
$sth = $dbh-&#62;prepare( "$sql" );
$s [...]]]></description>
			<content:encoded><![CDATA[<pre>$sql = "INSERT INTO `db_01` ( data1, data2 ) VALUES ( $data1, $data2 )";
$sth = $dbh-&gt;prepare( "$sql" );
$sth-&gt;execute();
$id = $sth-&gt;{mysql_insertid};</pre>
<p>これで$idに「自分が追加した最新のauto_increment番号」が代入される</p>
<p>ただし下記のようにdoでは使えない。</p>
<pre>$sql = "INSERT INTO `db_01` ( data1, data2 ) VALUES ( $data1, $data2 )";
$sth = $dbh-&gt;do( "$sql" );
$id = $sth-&gt;{mysql_insertid};</pre>
]]></content:encoded>
			<wfw:commentRss>http://perl.no-tubo.net/2008/10/03/%e8%87%aa%e5%88%86%e3%81%8c%e8%bf%bd%e5%8a%a0%e3%81%97%e3%81%9f%e6%9c%80%e6%96%b0%e3%81%aeauto_increment%e7%95%aa%e5%8f%b7%e3%82%92%e5%8f%96%e5%be%97%e3%81%99%e3%82%8b-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
