<?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.mktime.com/archive/category/mysql/feed" rel="self" type="application/rss+xml" />
	<link>http://blog.mktime.com</link>
	<description>修行の日々を淡々と</description>
	<lastBuildDate>Thu, 05 May 2011 07:39:25 +0000</lastBuildDate>
	<language>ja</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.2</generator>
		<item>
		<title>mysql：configure: error: Cannot find libmysqlclient under /usr</title>
		<link>http://blog.mktime.com/archive/290.html</link>
		<comments>http://blog.mktime.com/archive/290.html#comments</comments>
		<pubDate>Mon, 07 Jun 2010 10:52:11 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[mysql]]></category>
		<category><![CDATA[エラー]]></category>

		<guid isPermaLink="false">http://blog.mktime.com/?p=290</guid>
		<description><![CDATA[mysql5のconfigureで以下のようなメッセージが出るとき、 configure: error: Cannot find libmysqlclient under /usr/local. Note that the MySQL client library is not bundled anymore! かつ、アーキテクチャが64のときは./configure オプションに &#8211;with-mysql=/usr/bin/ &#8211;with-libdir=lib64 が足りない。 アーキテクチャの確認方法は uname -r]]></description>
			<content:encoded><![CDATA[<p>mysql5のconfigureで以下のようなメッセージが出るとき、</p>
<pre class="error">
configure: error: Cannot find libmysqlclient under /usr/local.
Note that the MySQL client library is not bundled anymore!
</pre>
<p>かつ、アーキテクチャが64のときは./configure オプションに<br />
 &#8211;with-mysql=/usr/bin/ &#8211;with-libdir=lib64<br />
が足りない。</p>
<p>アーキテクチャの確認方法は</p>
<div class="console">
uname -r
</div>
]]></content:encoded>
			<wfw:commentRss>http://blog.mktime.com/archive/290.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>mysql: mysql5.1.41をソースからインストール</title>
		<link>http://blog.mktime.com/archive/237.html</link>
		<comments>http://blog.mktime.com/archive/237.html#comments</comments>
		<pubDate>Sun, 24 Jan 2010 03:20:29 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[mysql]]></category>

		<guid isPermaLink="false">http://blog.mktime.com/?p=237</guid>
		<description><![CDATA[mysqlをソースからインストールする。 pluginは全部有効にする。 cd /usr/local/src wget http://dev.mysql.com/get/Downloads/MySQL-5.1/mysql-5.1.41.tar.gz/from/http://ftp.iij.ad.jp/pub/db/mysql/ tar zxfv mysql-5.1.41.tar.gz cd mysql-5.1.41 ./configure &#8211;prefix=/usr/local/mysql &#8211;with-charset=utf8 &#8211;with-extra-charsets=all &#8211;with-mysqld-user=mysql &#8211;with-plugins=max &#8211;enable-local-infile make make install 以上でインストールは完了。 ※この段階でエラーが出る場合は後述のエラーがでるときを参照 次に初期設定をおこなう。 ソースの雛形からmy.cnf を作成する。 cp support-files/my-medium.cnf /etc/my.cnf 作成したmy.cnf に文字コードの設定を追加する。 mysqld、mysqldump、mysql セクションにそれぞれ以下の設定を追加する。 [mysqld] default-character-set=utf8 skip-character-set-client-handshake character-set-server = utf8 collation-server = utf8_general_ci init-connect = SET NAMES utf8 [mysqldump] default-character-set = utf8 [mysql] default-character-set = utf8 [...]]]></description>
			<content:encoded><![CDATA[<p>mysqlをソースからインストールする。<br />
pluginは全部有効にする。</p>
<div class="console">
cd /usr/local/src<br />
wget http://dev.mysql.com/get/Downloads/MySQL-5.1/mysql-5.1.41.tar.gz/from/http://ftp.iij.ad.jp/pub/db/mysql/<br />
tar zxfv mysql-5.1.41.tar.gz<br />
cd mysql-5.1.41<br />
./configure &#8211;prefix=/usr/local/mysql<br />
&#8211;with-charset=utf8<br />
&#8211;with-extra-charsets=all<br />
&#8211;with-mysqld-user=mysql<br />
&#8211;with-plugins=max<br />
&#8211;enable-local-infile<br />
make<br />
make install
</div>
<p>以上でインストールは完了。<br />
※この段階でエラーが出る場合は後述の<a href="#error">エラーがでるとき</a>を参照</p>
<p>次に初期設定をおこなう。<br />
ソースの雛形からmy.cnf を作成する。</p>
<div class="console">
cp support-files/my-medium.cnf /etc/my.cnf
</div>
<p>作成したmy.cnf に文字コードの設定を追加する。<br />
mysqld、mysqldump、mysql セクションにそれぞれ以下の設定を追加する。</p>
<div class="file">
[mysqld]<br />
default-character-set=utf8<br />
skip-character-set-client-handshake<br />
character-set-server = utf8<br />
collation-server = utf8_general_ci<br />
init-connect = SET NAMES utf8<br />
[mysqldump]<br />
default-character-set = utf8<br />
[mysql]<br />
default-character-set = utf8
</div>
<p>mysqlを起動する前に、mysql 用のユーザを追加する。</p>
<div class="console">
groupadd mysql<br />
useradd -g mysql mysql
</div>
<p>mysql のインストールフォルダのオーナーをmysql ユーザに変更する。</p>
<div class="console">
chown -R mysql:mysql /usr/local/mysql
</div>
<p>次に、データベースを初期化を行う。</p>
<div class="console">
cd /usr/local/mysql<br />
bin/mysql_install_db &#8211;user=mysql
</div>
<p>MySQL サーバーを起動する。</p>
<div class="console">
./bin/mysqld_safe &#8211;user=mysql &#038;
</div>
<p>※mysql起動後はrootユーザログインできるようになる。<br />
初期状態ではrootにパスワードが設定されていないので、必ずrootユーザのパスワードを設定すること。</p>
<p><a name="error"></a></p>
<h4>mysqlのconfigure,makeでエラーがでるとき</h4>
<p>もし./configureでこんなエラーがでたら</p>
<pre class="error">
checking for termcap functions library... configure: error: No curses/termcap library found
</pre>
<p>ncurses-develというものをインストールすればconfigureできるようになる。</p>
<div class="console">
yum install ncurses-devel
</div>
<p>もしmakeでこんなエラーがでたら</p>
<pre class="error">
../depcomp: line 571: exec: g++: not found
make[1]: *** [my_new.o] エラー 127
make[1]: ディレクトリ `/usr/local/src/mysql-5.1.41/mysys' から出ます
make:
</pre>
<p>gcc-c++をインストールする。</p>
<div class="console">
yum install gcc-c++
</div>
<p>このままmakeすると、以下のようなエラーになるので、</p>
<pre class="error">
licit-templates -fno-exceptions -fno-rtti -c -o my_new.o my_new.cc
../include/my_global.h:1099: error: redeclaration of C++ built-in type 'bool'
</pre>
<p>make cleanしてconfigureからやりなおすこと。</p>
<div class="console">
make clean<br />
./configure &#8211;prefix=/usr/local/mysql<br />
&#8211;with-charset=utf8<br />
&#8211;with-extra-charsets=all<br />
&#8211;with-mysqld-user=mysql<br />
&#8211;with-plugins=max<br />
&#8211;enable-local-infile </p>
<p>make</p>
<p>make install
</p></div>
]]></content:encoded>
			<wfw:commentRss>http://blog.mktime.com/archive/237.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>mysql：PL/SQLでCursor declaration after handler declaration</title>
		<link>http://blog.mktime.com/archive/217.html</link>
		<comments>http://blog.mktime.com/archive/217.html#comments</comments>
		<pubDate>Tue, 25 Aug 2009 10:32:01 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[mysql]]></category>

		<guid isPermaLink="false">http://blog.mktime.com/?p=217</guid>
		<description><![CDATA[mysqlのPL/SQLでこんなエラーは出るとき ERROR 1338 (42000): Cursor declaration after handler declaration 意味：カーソル宣言がハンドラ宣言よりあとで行われています。 Variable or condition declaration after cursor or handler declaration 意味：変数または条件宣言がカーソルまたはハンドラ宣言より後で行われています。 つまりPL/SQLの宣言は変数、条件、カーソル、ハンドラの順で行えということですね。 CREATE PROCEDURE procname( in arg1 VARCHAR(10), in arg2 VARCHAR(20) ) BEGIN -- 変数宣言 DECLARE UserName VARCHAR(10); DECLARE done INT DEFAULT 0; -- カーソル宣言 DECLARE cur_name CURSOR FOR SELECT user_name FROM table_name WHERE user_prop = [...]]]></description>
			<content:encoded><![CDATA[<p>mysqlのPL/SQLでこんなエラーは出るとき</p>
<h4>ERROR 1338 (42000): Cursor declaration after handler declaration</h4>
<p>意味：カーソル宣言がハンドラ宣言よりあとで行われています。</p>
<h4>Variable or condition declaration after cursor or handler declaration</h4>
<p>意味：変数または条件宣言がカーソルまたはハンドラ宣言より後で行われています。</p>
<p>つまりPL/SQLの宣言は変数、条件、カーソル、ハンドラの順で行えということですね。</p>
<pre>
CREATE PROCEDURE procname(
    in  arg1   VARCHAR(10),
    in  arg2   VARCHAR(20)
)
BEGIN
    -- 変数宣言
    DECLARE UserName     VARCHAR(10);
    DECLARE done INT DEFAULT 0;

    -- カーソル宣言
    DECLARE cur_name CURSOR FOR
        SELECT user_name
        FROM table_name
        WHERE user_prop = arg1;

    -- ハンドラ宣言
    DECLARE CONTINUE HANDLER FOR SQLSTATE '02000' SET done = 1;

    -- 処理開始
    OPEN cur_name;
    REPEAT
        FETCH cur_name INTO UserName;
        IF NOT done THEN
            -- いろいろ
        END If;
    UNTIL done END REPEAT;
    CLOSE cur_name;
END;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.mktime.com/archive/217.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>mysql：テーブルのrepair</title>
		<link>http://blog.mktime.com/archive/209.html</link>
		<comments>http://blog.mktime.com/archive/209.html#comments</comments>
		<pubDate>Wed, 15 Jul 2009 00:42:50 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[mysql]]></category>
		<category><![CDATA[crash]]></category>
		<category><![CDATA[error]]></category>

		<guid isPermaLink="false">http://blog.mktime.com/?p=209</guid>
		<description><![CDATA[mysqlでこんなエラーメッセージが出てた。 Table table_name is marked as crashed and should be repaired とりあえず、エラーが出ているテーブルを調べる。 mysql> check table table_name; +&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;-+&#8212;&#8212;&#8212;-+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-+ &#124; Table &#124; Op &#124; Msg_type &#124; Msg_text &#124; +&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;-+&#8212;&#8212;&#8212;-+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-+ &#124; table_name &#124; check &#124; warning &#124; Table is marked as crashed &#124; &#124; table_name &#124; check &#124; warning &#124; 1 client is using or hasn&#8217;t closed the [...]]]></description>
			<content:encoded><![CDATA[<p>mysqlでこんなエラーメッセージが出てた。</p>
<h4>Table table_name is marked as crashed and should be repaired</h4>
<p>とりあえず、エラーが出ているテーブルを調べる。</p>
<div class="console">
mysql> check table table_name;<br />
+&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;-+&#8212;&#8212;&#8212;-+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-+<br />
| Table      | Op    | Msg_type | Msg_text                                              |<br />
+&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;-+&#8212;&#8212;&#8212;-+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-+<br />
| table_name | check | warning  | Table is marked as crashed                            |<br />
| table_name | check | warning  | 1 client is using or hasn&#8217;t closed the table properly |<br />
| table_name | check | error    | Record at pos: 482160 is not remove-marked            |<br />
| table_name | check | error    | record delete-link-chain corrupted                    |<br />
| table_name | check | error    | Corrupt                                               |<br />
+&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;-+&#8212;&#8212;&#8212;-+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-+
</div>
<p>確かにテーブルにエラーがある。<br />
これを直すにはrepairコマンドを使うらしい。</p>
<div class="console">
mysql> repair table table_name;<br />
+&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;&#8211;+&#8212;&#8212;&#8212;-+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;+<br />
| Table      | Op     | Msg_type | Msg_text                             |<br />
+&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;&#8211;+&#8212;&#8212;&#8212;-+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;+<br />
| table_name | repair | warning  | Number of rows changed from 63 to 64 |<br />
| table_name | repair | status   | OK                                   |<br />
+&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;&#8211;+&#8212;&#8212;&#8212;-+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;+
</div>
<p>これで直ったっぽい。<br />
どうしてこの手順で直るのかはいつか調べる。</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.mktime.com/archive/209.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>mysql：DATETIME型とTIMESTAMP型</title>
		<link>http://blog.mktime.com/archive/196.html</link>
		<comments>http://blog.mktime.com/archive/196.html#comments</comments>
		<pubDate>Fri, 05 Jun 2009 10:22:23 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[mysql]]></category>
		<category><![CDATA[datetime]]></category>
		<category><![CDATA[timestamp]]></category>

		<guid isPermaLink="false">http://blog.mktime.com/?p=196</guid>
		<description><![CDATA[DATETIME型は8バイト、TIMESTAMP型は4バイト。 サポートする日付の範囲は DATETIME： 0000年～9999年 TIMESTAMP： 1970年～2037年 4バイトくらいケチらずにDATETIME型を使うのが基本か。 TIMESTAMP型で更新日時など内部データを持つのはアリかもしれない。 けど、生年月日のようなデータ入れられない。 システムの中で何種類も日付型を使うのが面倒ならDATETIME型に統一したほうがいい。]]></description>
			<content:encoded><![CDATA[<p>DATETIME型は8バイト、TIMESTAMP型は4バイト。<br />
サポートする日付の範囲は<br />
DATETIME： 0000年～9999年<br />
TIMESTAMP： 1970年～2037年</p>
<p>4バイトくらいケチらずにDATETIME型を使うのが基本か。<br />
TIMESTAMP型で更新日時など内部データを持つのはアリかもしれない。<br />
けど、生年月日のようなデータ入れられない。<br />
システムの中で何種類も日付型を使うのが面倒ならDATETIME型に統一したほうがいい。</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.mktime.com/archive/196.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>mysql：リモートログインできるユーザの追加</title>
		<link>http://blog.mktime.com/archive/193.html</link>
		<comments>http://blog.mktime.com/archive/193.html#comments</comments>
		<pubDate>Wed, 03 Jun 2009 02:26:20 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[mysql]]></category>

		<guid isPermaLink="false">http://blog.mktime.com/?p=193</guid>
		<description><![CDATA[mysqlにリモートログインできるユーザを追加するコマンド GRANT ALL PRIVILEGES ON DBNAME.* TO username@&#8221;%&#8221; IDENTIFIED BY &#8216;password&#8217; WITH GRANT OPTION; FLUSH PRIVILEGES; &#8220;%&#8221;のところにIPアドレスを指定してアクセスできる接続元IPを指定することができる。 &#8220;%&#8221;なら何処からでも接続可になる。]]></description>
			<content:encoded><![CDATA[<p>mysqlにリモートログインできるユーザを追加するコマンド</p>
<div class="console">
GRANT ALL PRIVILEGES ON DBNAME.* TO username@&#8221;%&#8221; IDENTIFIED BY &#8216;password&#8217; WITH GRANT OPTION;<br />
FLUSH PRIVILEGES;
</div>
<p>&#8220;%&#8221;のところにIPアドレスを指定してアクセスできる接続元IPを指定することができる。<br />
&#8220;%&#8221;なら何処からでも接続可になる。</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.mktime.com/archive/193.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>mysql：mysql6のソースインストールでconfigure: WARNING: unrecognized options</title>
		<link>http://blog.mktime.com/archive/127.html</link>
		<comments>http://blog.mktime.com/archive/127.html#comments</comments>
		<pubDate>Sun, 03 May 2009 14:32:29 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[mysql]]></category>
		<category><![CDATA[configure]]></category>
		<category><![CDATA[mysql6]]></category>

		<guid isPermaLink="false">http://blog.mktime.com/?p=127</guid>
		<description><![CDATA[mysql6をソースからインストールしようとしたらconfigureのところでこんなエラーが configure: WARNING: unrecognized options: &#8211;with-innodb そんなわけねー、と思いつつ調べたら最近はこう指定するらしい。 --with-plugins=partition,blackhole,heap,innobase,myisam,ndbcluster,maria これで無事にconfigureとおりました。]]></description>
			<content:encoded><![CDATA[<p>mysql6をソースからインストールしようとしたらconfigureのところでこんなエラーが</p>
<h4>
configure: WARNING: unrecognized options: &#8211;with-innodb<br />
</h4>
<p>そんなわけねー、と思いつつ調べたら最近はこう指定するらしい。</p>
<pre class="console">
--with-plugins=partition,blackhole,heap,innobase,myisam,ndbcluster,maria
</pre>
<p>これで無事にconfigureとおりました。</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.mktime.com/archive/127.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>mysql：MySQLのバックアップとリストア</title>
		<link>http://blog.mktime.com/archive/86.html</link>
		<comments>http://blog.mktime.com/archive/86.html#comments</comments>
		<pubDate>Sun, 12 Apr 2009 12:33:38 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[mysql]]></category>
		<category><![CDATA[dump]]></category>
		<category><![CDATA[バックアップ]]></category>

		<guid isPermaLink="false">http://blog.mktime.com/?p=86</guid>
		<description><![CDATA[mysqldumpでバックアップ＆リストア すべてのデータベースをdumpでバックアップ $ mysqldump -u root -p -x &#8211;all-databases > dump.sql 特定のデータベースをバックアップするときは $ mysqldump -u root -p データベース名 > dump.sql すべてのデータベースを復元するときは $ mysql -u root -p < dump.sql 特定のデータベースを復元するときは $ mysql -u root -p データベース名 < dump.sql]]></description>
			<content:encoded><![CDATA[<p>mysqldumpでバックアップ＆リストア</p>
<p>すべてのデータベースをdumpでバックアップ</p>
<div class="console">
$ mysqldump -u root -p -x &#8211;all-databases > dump.sql
</div>
<p>特定のデータベースをバックアップするときは</p>
<div class="console">
$ mysqldump -u root -p データベース名 > dump.sql
</div>
<p>すべてのデータベースを復元するときは</p>
<div class="console">
$ mysql -u root -p < dump.sql
</div>
<p>特定のデータベースを復元するときは</p>
<div class="console">
$ mysql -u root -p データベース名 < dump.sql
</div>
]]></content:encoded>
			<wfw:commentRss>http://blog.mktime.com/archive/86.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>mysql：mysqlとsennaのインストール</title>
		<link>http://blog.mktime.com/archive/83.html</link>
		<comments>http://blog.mktime.com/archive/83.html#comments</comments>
		<pubDate>Sun, 12 Apr 2009 12:29:11 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[mysql]]></category>
		<category><![CDATA[senna]]></category>

		<guid isPermaLink="false">http://blog.mktime.com/?p=83</guid>
		<description><![CDATA[yumで要るものを全部入れる。 yum install mecab yum install mecab-ipadic yum install senna yum install MySQL-shared yum install MySQL-client yum install MySQL-server mysql -urootでログインして、↓このように&#8221;Tritonn Project&#8221;のバージョンが表示されればOK。 mysql -Vでは表示されないので注意。 Welcome to the MySQL monitor. Commands end with ; or g. Your MySQL connection id is 2419 Server version: 5.0.51a-modified-log MySQL Community Server (GPL) (portions (c) Tritonn Project) Type 'help;' or [...]]]></description>
			<content:encoded><![CDATA[<p>yumで要るものを全部入れる。</p>
<div class="console">
yum install mecab<br />
yum install mecab-ipadic<br />
yum install senna<br />
yum install MySQL-shared<br />
yum install MySQL-client<br />
yum install MySQL-server
</div>
<p>mysql -urootでログインして、↓このように&#8221;Tritonn Project&#8221;のバージョンが表示されればOK。 mysql -Vでは表示されないので注意。</p>
<pre>
Welcome to the MySQL monitor.  Commands end with ; or g.
Your MySQL connection id is 2419
Server version: 5.0.51a-modified-log MySQL Community Server (GPL) (portions (c) Tritonn Project)

Type 'help;' or 'h' for help. Type 'c' to clear the buffer.
</pre>
<p>mysqlインストール後の儀式、rootのパスワードを変更する。</p>
<div class="console">
mysqladmin -u root password パスワード
</div>
<p>次にmy.cnfを設定する。<br />
/usr/share/mysql/にある雛形を使ってmy.cnfを作成する。雛形はサーバスペックにあわせて選ぶ。意味なく大きいのにしないこと。 </p>
<table class="table">
<caption> my.cnf雛形選択の目安<br />
</caption>
<tr>
<th> my-small.cnf
</th>
<td> 64Mバイト以下のメモリの小規模サーバー向け
</td>
</tr>
<tr>
<th> my-medium.cnf
</th>
<td> 32M～64Mバイトのメモリを持つMySQL専用サーバーか、128Mバイトのメモリを持つサーバー向け
</td>
</tr>
<tr>
<th> my-large.cnf
</th>
<td> 	512Mバイト程度のメモリを持ち、MySQL専用となる機械向け
</td>
</tr>
<tr>
<th> my-huge.cnf
</th>
<td> 1G～2Gバイトのメモリを持つMySQL専用サーバー向け
</td>
</tr>
<tr>
<th> my-innodb-heavy-4G.cnf
</th>
<td> 4Gバイトのメモリ、InnoDBのみ、ACID、少ない接続、大量のクエリ
</td>
</tr>
</table>
<p>/etc/my.cnfを作る</p>
<div class="console">
cp /usr/share/mysql/my-medium.cnf /etc/my.cnf
</div>
<p>デフォルトUTF8で使うときの文字コードの設定をmy.cnfに追加する</p>
<div class="caption">/etc/my.cnf</div>
<div class="file">
[mysqld]<br />
default-character-set=utf8<br />
skip-character-set-client-handshake<br />
character-set-server = utf8<br />
collation-server = utf8_general_ci<br />
init-connect = SET NAMES utf8</p>
<p>[mysqldump]<br />
default-character-set = utf8</p>
<p>[mysql]<br />
default-character-set = utf8
</p></div>
]]></content:encoded>
			<wfw:commentRss>http://blog.mktime.com/archive/83.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MySQL:auto_incrementが最大値まで達したとき</title>
		<link>http://blog.mktime.com/archive/46.html</link>
		<comments>http://blog.mktime.com/archive/46.html#comments</comments>
		<pubDate>Sun, 27 Jul 2008 14:07:57 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[mysql]]></category>
		<category><![CDATA[bigint]]></category>
		<category><![CDATA[int]]></category>
		<category><![CDATA[sutoincrement]]></category>

		<guid isPermaLink="false">http://blog.mktime.com/?p=46</guid>
		<description><![CDATA[auto_incrementにしたカラムの型がintなら2147483647、bigintなら9223372036854775807がautoincrementの最大になる。 実際に最大値までauto_incrementを進めてみる。 ALTER TABLE table1 AUTO_INCREMENT= 2147483647; auto_incrementが最大値に達するともうそのテーブルには行を追加することはできなくなります。 oracleのシーケンスならCYCLEオプションがあるけどmysqlのauto_incrementにはそのような機能は無いらしい。 ではauto_incrementが最大値に達したとき、どうすればよいのか？ 単純に ALTER TABLE table1 AUTO_INCREMENT= 1; としても、table1に1より大きいキーが存在する限りauto_incrementは1に戻らない。 DELETE FROM table1; --データを全部消す。 ALTER TABLE table1 AUTO_INCREMENT= 1; ならばauto_incrementは1に戻るので、循環シーケンスと似たような動きにするにはINSERTトリガーで 1. 対象テーブルのauto_increment値が最大に達しているかチェック。最大なら2.へ 2. 対象テーブルのデータを別テーブルに退避 3. 対象テーブルのデータをDELETE 4. ALTER TABLE～でauto_incrementを初期値に設定 という流れになるけど、INSERTの度に1.のチェックを走らせるのはちょっと嫌（1/2147483647の為に余計な処理を入れたくない）。また、退避後のデータをどう扱うかも微妙（UNIONするにしても別のキーが要るし・・・）だから int autoincrementでキーの枯渇が心配ならbigint型にしたほうがよいと思う。 bigintの最大値は9223372036854775807。intの約42億倍もある。 これは1日に1億個のキーを消費しても2億年持つという計算になる。]]></description>
			<content:encoded><![CDATA[<p>auto_incrementにしたカラムの型がintなら2147483647、bigintなら9223372036854775807がautoincrementの最大になる。</p>
<p>実際に最大値までauto_incrementを進めてみる。</p>
<pre class="console">
 ALTER TABLE table1 AUTO_INCREMENT= 2147483647;
</pre>
<p>auto_incrementが最大値に達するともうそのテーブルには行を追加することはできなくなります。</p>
<p>oracleのシーケンスならCYCLEオプションがあるけどmysqlのauto_incrementにはそのような機能は無いらしい。</p>
<p>ではauto_incrementが最大値に達したとき、どうすればよいのか？</p>
<p>単純に</p>
<pre class="console">
 ALTER TABLE table1 AUTO_INCREMENT= 1;
</pre>
<p>としても、table1に1より大きいキーが存在する限りauto_incrementは1に戻らない。</p>
<pre class="console">
 DELETE FROM table1; --データを全部消す。
 ALTER TABLE table1 AUTO_INCREMENT= 1;
</pre>
<p>ならばauto_incrementは1に戻るので、循環シーケンスと似たような動きにするにはINSERTトリガーで</p>
<p>1. 対象テーブルのauto_increment値が最大に達しているかチェック。最大なら2.へ<br />
2. 対象テーブルのデータを別テーブルに退避<br />
3. 対象テーブルのデータをDELETE<br />
4. ALTER TABLE～でauto_incrementを初期値に設定</p>
<p>という流れになるけど、INSERTの度に1.のチェックを走らせるのはちょっと嫌（1/2147483647の為に余計な処理を入れたくない）。また、退避後のデータをどう扱うかも微妙（UNIONするにしても別のキーが要るし・・・）だから<br />
int autoincrementでキーの枯渇が心配ならbigint型にしたほうがよいと思う。<br />
bigintの最大値は9223372036854775807。intの約42億倍もある。<br />
これは1日に1億個のキーを消費しても2億年持つという計算になる。</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.mktime.com/archive/46.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

