<?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://sabakan.org/p/blog/category/mysql/feed/" rel="self" type="application/rss+xml" />
	<link>http://sabakan.org/p/blog</link>
	<description>主にコンピュータとOSSに関する覚書</description>
	<lastBuildDate>Sun, 05 Feb 2012 11:13:13 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>ja</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>mysql_secure_installation</title>
		<link>http://sabakan.org/p/blog/2011/01/17/mysql_secure_installation/</link>
		<comments>http://sabakan.org/p/blog/2011/01/17/mysql_secure_installation/#comments</comments>
		<pubDate>Sun, 16 Jan 2011 16:09:36 +0000</pubDate>
		<dc:creator>root</dc:creator>
				<category><![CDATA[MySQL]]></category>

		<guid isPermaLink="false">http://sabakan.org/p/blog/?p=291</guid>
		<description><![CDATA[
			
				
			
		
MySQLをセキュアに運用するための基本として、インストール直後に
mysql_secure_installationを使うと良いかもしれない。
rootのパスワードの設定や余分な設定の削除などをやってくれる。
使い方は簡単。


[root@epsilon ~] mysql_secure_installation

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!

In order to log into MySQL to secure it, we'll need the current
password for the root user.  If you've just installed MySQL, and
you haven't set the [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fsabakan.org%2Fp%2Fblog%2F2011%2F01%2F17%2Fmysql_secure_installation%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fsabakan.org%2Fp%2Fblog%2F2011%2F01%2F17%2Fmysql_secure_installation%2F&amp;source=bokkoware&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>MySQLをセキュアに運用するための基本として、インストール直後に<br />
mysql_secure_installationを使うと良いかもしれない。<br />
rootのパスワードの設定や余分な設定の削除などをやってくれる。</p>
<p>使い方は簡単。<br />
<span id="more-291"></span></p>
<pre class="brush: plain;">
[root@epsilon ~] mysql_secure_installation

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!

In order to log into MySQL to secure it, we'll need the current
password for the root user.  If you've just installed MySQL, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.

Enter current password for root (enter for none):
OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MySQL
root user without the proper authorisation.

Set root password? [Y/n]
Setting the root password ensures that nobody can log into the MySQL
root user without the proper authorisation.

Set root password? [Y/n] y
New password:
Re-enter new password:
Password updated successfully!
Reloading privilege tables..
 ... Success!
By default, a MySQL installation has an anonymous user, allowing anyone
to log into MySQL without having to have a user account created for
them.  This is intended only for testing, and to make the installation
go a bit smoother.  You should remove them before moving into a
production environment.

Remove anonymous users? [Y/n] y
 ... Success!

Normally, root should only be allowed to connect from 'localhost'.  This
ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] y
 ... Success!

By default, MySQL comes with a database named 'test' that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.

Remove test database and access to it? [Y/n] y
 - Dropping test database...
 ... Success!
 - Removing privileges on test database...
 ... Success!

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y/n] y
 ... Success!

Cleaning up...

All done!  If you've completed all of the above steps, your MySQL
installation should now be secure.

Thanks for using MySQL!
</pre>
]]></content:encoded>
			<wfw:commentRss>http://sabakan.org/p/blog/2011/01/17/mysql_secure_installation/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CREATE TABLE、INSERT時に他のテーブルのレコードを挿入</title>
		<link>http://sabakan.org/p/blog/2011/01/04/create-table%e3%80%81insert%e6%99%82%e3%81%ab%e4%bb%96%e3%81%ae%e3%83%86%e3%83%bc%e3%83%96%e3%83%ab%e3%81%ae%e3%83%ac%e3%82%b3%e3%83%bc%e3%83%89%e6%8c%bf%e5%85%a5/</link>
		<comments>http://sabakan.org/p/blog/2011/01/04/create-table%e3%80%81insert%e6%99%82%e3%81%ab%e4%bb%96%e3%81%ae%e3%83%86%e3%83%bc%e3%83%96%e3%83%ab%e3%81%ae%e3%83%ac%e3%82%b3%e3%83%bc%e3%83%89%e6%8c%bf%e5%85%a5/#comments</comments>
		<pubDate>Mon, 03 Jan 2011 16:12:21 +0000</pubDate>
		<dc:creator>root</dc:creator>
				<category><![CDATA[MySQL]]></category>

		<guid isPermaLink="false">http://sabakan.org/p/blog/?p=287</guid>
		<description><![CDATA[
			
				
			
		
これは便利。

CREATE TABLE deviceInfo_Tmp ENGINE = MYISAM AS
SELECT * FROM deviceInfo
WHERE width &#62;= 480

INSERT INTO deviceInfo SELECT * FROM deviceInfo_Tmp

]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fsabakan.org%2Fp%2Fblog%2F2011%2F01%2F04%2Fcreate-table%25e3%2580%2581insert%25e6%2599%2582%25e3%2581%25ab%25e4%25bb%2596%25e3%2581%25ae%25e3%2583%2586%25e3%2583%25bc%25e3%2583%2596%25e3%2583%25ab%25e3%2581%25ae%25e3%2583%25ac%25e3%2582%25b3%25e3%2583%25bc%25e3%2583%2589%25e6%258c%25bf%25e5%2585%25a5%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fsabakan.org%2Fp%2Fblog%2F2011%2F01%2F04%2Fcreate-table%25e3%2580%2581insert%25e6%2599%2582%25e3%2581%25ab%25e4%25bb%2596%25e3%2581%25ae%25e3%2583%2586%25e3%2583%25bc%25e3%2583%2596%25e3%2583%25ab%25e3%2581%25ae%25e3%2583%25ac%25e3%2582%25b3%25e3%2583%25bc%25e3%2583%2589%25e6%258c%25bf%25e5%2585%25a5%2F&amp;source=bokkoware&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>これは便利。</p>
<pre class="brush: plain;">
CREATE TABLE deviceInfo_Tmp ENGINE = MYISAM AS
SELECT * FROM deviceInfo
WHERE width &gt;= 480

INSERT INTO deviceInfo SELECT * FROM deviceInfo_Tmp
</pre>
]]></content:encoded>
			<wfw:commentRss>http://sabakan.org/p/blog/2011/01/04/create-table%e3%80%81insert%e6%99%82%e3%81%ab%e4%bb%96%e3%81%ae%e3%83%86%e3%83%bc%e3%83%96%e3%83%ab%e3%81%ae%e3%83%ac%e3%82%b3%e3%83%bc%e3%83%89%e6%8c%bf%e5%85%a5/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MyISAMのデータがご臨終した？</title>
		<link>http://sabakan.org/p/blog/2009/06/26/myisam%e3%81%ae%e3%83%87%e3%83%bc%e3%82%bf%e3%81%8c%e3%81%94%e8%87%a8%e7%b5%82%e3%81%97%e3%81%9f%ef%bc%9f/</link>
		<comments>http://sabakan.org/p/blog/2009/06/26/myisam%e3%81%ae%e3%83%87%e3%83%bc%e3%82%bf%e3%81%8c%e3%81%94%e8%87%a8%e7%b5%82%e3%81%97%e3%81%9f%ef%bc%9f/#comments</comments>
		<pubDate>Thu, 25 Jun 2009 18:36:03 +0000</pubDate>
		<dc:creator>root</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[MySQL]]></category>

		<guid isPermaLink="false">http://sabakan.org/p/blog/?p=112</guid>
		<description><![CDATA[
			
				
			
		
突然、MySQLのテーブルのデータがselectできなくなった(&#8216;A`) 。
もしかして、MyISAMのテーブルがぶっとんだのか？
グーグル先生でmyisamchkというものを発見したので使ってみた。
# myisamchk db/daily_report.MYI
Checking MyISAM file: db/daily_report.MYI
Data records: 69451 Deleted blocks: 0
myisamchk: warning: 2 clients are using or haven&#8217;t closed the table properly
- check file-size
- check record delete-chain
- check key delete-chain
- check index reference
- check data record references index: 1
- check record links
MyISAM-table &#8216;db/daily_report.MYI&#8217; is usable but should be fixed
これは、データは残ってるけど読み出せない状態になっているという
ことなのかな・・・・・
とりあえず、壊れているテーブルをダンプしてリストアしたら
selectできるようになったが、解決方法としては良かったのかな・・・・。
]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fsabakan.org%2Fp%2Fblog%2F2009%2F06%2F26%2Fmyisam%25e3%2581%25ae%25e3%2583%2587%25e3%2583%25bc%25e3%2582%25bf%25e3%2581%258c%25e3%2581%2594%25e8%2587%25a8%25e7%25b5%2582%25e3%2581%2597%25e3%2581%259f%25ef%25bc%259f%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fsabakan.org%2Fp%2Fblog%2F2009%2F06%2F26%2Fmyisam%25e3%2581%25ae%25e3%2583%2587%25e3%2583%25bc%25e3%2582%25bf%25e3%2581%258c%25e3%2581%2594%25e8%2587%25a8%25e7%25b5%2582%25e3%2581%2597%25e3%2581%259f%25ef%25bc%259f%2F&amp;source=bokkoware&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>突然、MySQLのテーブルのデータがselectできなくなった(&#8216;A`) 。<br />
もしかして、MyISAMのテーブルがぶっとんだのか？<br />
グーグル先生でmyisamchkというものを発見したので使ってみた。</p>
<p># myisamchk db/daily_report.MYI<br />
Checking MyISAM file: db/daily_report.MYI<br />
Data records: 69451 Deleted blocks: 0<br />
myisamchk: warning: 2 clients are using or haven&#8217;t closed the table properly<br />
- check file-size<br />
- check record delete-chain<br />
- check key delete-chain<br />
- check index reference<br />
- check data record references index: 1<br />
- check record links<br />
MyISAM-table &#8216;db/daily_report.MYI&#8217; is usable but should be fixed</p>
<p>これは、データは残ってるけど読み出せない状態になっているという<br />
ことなのかな・・・・・</p>
<p>とりあえず、壊れているテーブルをダンプしてリストアしたら<br />
selectできるようになったが、解決方法としては良かったのかな・・・・。</p>
]]></content:encoded>
			<wfw:commentRss>http://sabakan.org/p/blog/2009/06/26/myisam%e3%81%ae%e3%83%87%e3%83%bc%e3%82%bf%e3%81%8c%e3%81%94%e8%87%a8%e7%b5%82%e3%81%97%e3%81%9f%ef%bc%9f/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MySQLのバックアップ＆リストア＆リカバリ</title>
		<link>http://sabakan.org/p/blog/2009/01/12/mysql%e3%81%ae%e3%83%90%e3%83%83%e3%82%af%e3%82%a2%e3%83%83%e3%83%97%ef%bc%86%e3%83%aa%e3%82%b9%e3%83%88%e3%82%a2%ef%bc%86%e3%83%aa%e3%82%ab%e3%83%90%e3%83%aa/</link>
		<comments>http://sabakan.org/p/blog/2009/01/12/mysql%e3%81%ae%e3%83%90%e3%83%83%e3%82%af%e3%82%a2%e3%83%83%e3%83%97%ef%bc%86%e3%83%aa%e3%82%b9%e3%83%88%e3%82%a2%ef%bc%86%e3%83%aa%e3%82%ab%e3%83%90%e3%83%aa/#comments</comments>
		<pubDate>Mon, 12 Jan 2009 14:11:06 +0000</pubDate>
		<dc:creator>root</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[MySQL]]></category>

		<guid isPermaLink="false">http://sabakan.org/p/blog/?p=10</guid>
		<description><![CDATA[
			
				
			
		
今日はMySQLのバックアップ＆リストア＆リカバリのお勉強をしたので
メモ。
テスト環境：
Redhat系Linux/MySQL : 5.0.27-0vl6。
シチュエーション:
ある日、突然データベースがぶっとんでしまった(’A`)、ので、
数日前に取っておいた全体バックアップとリアルタイムで更新される
バイナリログを使用してデータベースを復旧させる。
●まず、定期的にデータベースの全体バックアップ（権限テーブル含む。
# mysqldump &#45;&#45;user=root &#45;&#45;password=rootpass &#45;&#45;socket=/var/lib/mysql/mysql.sock
&#45;&#45;single-transaction &#45;&#45;master-data=2 &#45;&#45;flush-logs &#45;&#45;hex-blob
&#45;&#45;default-character-set=binary &#45;&#45;add-drop-table &#45;&#45;all-databases &#62; mysql-all.dump
（InnoDB以外のテーブルが含まれている場合は、共有ロックをかけるために
&#45;&#45;single-transactionをはずしましょう。
（&#45;&#45;flush-logsでバックアップと同時にbin-logもスイッチされる。
（/var/lib/mysqlにmysql-bin.000009が生成された
データベースが飛んだ・・・・・(’A`)
●Webアプリがデータベースを更新しないようにapacheをストップ
# service apache2 stop
●MySQLをストップ
# service mysql stop
●リストア、リカバリ時にバイナリログを生成しないように
my.cnfのlog-bin=mysql-binをコメントアウト
#log-bin=mysql-bin
●リモートから接続できなくするため&#45;&#45;skip-networkingオプションでmysql起動
# /usr/bin/mysqld_safe &#45;&#45;defaults-file=/etc/my.cnf &#45;&#45;skip-networking &#45;&#45;skip-grant-tables &#38;
[1] 28450
# Starting mysqld-max daemon with databases from /var/lib/mysql
●全体バックアップからリストア
# mysql &#45;&#45;user=root &#45;&#45;socket=/var/lib/mysql/mysql.sock
&#45;&#45;default-character-set=binary &#60; mysql-all.dump
●バイナリログでリカバリ
（全体バックアップ時に新たに生成されたmysql-bin.000009～を使う。
# mysqlbinlog &#45;&#45;disable-log-bin /var/lib/mysql/mysql-bin.000009 &#62; recover.sql
# mysql &#45;&#45;user=root &#45;&#45;password=rootpass &#45;&#45;socket=/var/lib/mysql/mysql.sock
&#45;&#45;default-character-set=binary &#60; recover.sql
●my.cnfのlog-bin=mysql-binを有効にする
log-bin=mysql-bin
●MySQL再起動
# service mysql stop
# service mysql start
これでＯＫ＾＾
かな？
]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fsabakan.org%2Fp%2Fblog%2F2009%2F01%2F12%2Fmysql%25e3%2581%25ae%25e3%2583%2590%25e3%2583%2583%25e3%2582%25af%25e3%2582%25a2%25e3%2583%2583%25e3%2583%2597%25ef%25bc%2586%25e3%2583%25aa%25e3%2582%25b9%25e3%2583%2588%25e3%2582%25a2%25ef%25bc%2586%25e3%2583%25aa%25e3%2582%25ab%25e3%2583%2590%25e3%2583%25aa%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fsabakan.org%2Fp%2Fblog%2F2009%2F01%2F12%2Fmysql%25e3%2581%25ae%25e3%2583%2590%25e3%2583%2583%25e3%2582%25af%25e3%2582%25a2%25e3%2583%2583%25e3%2583%2597%25ef%25bc%2586%25e3%2583%25aa%25e3%2582%25b9%25e3%2583%2588%25e3%2582%25a2%25ef%25bc%2586%25e3%2583%25aa%25e3%2582%25ab%25e3%2583%2590%25e3%2583%25aa%2F&amp;source=bokkoware&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>今日はMySQLのバックアップ＆リストア＆リカバリのお勉強をしたので<br />
メモ。</p>
<p><strong>テスト環境：</strong><br />
Redhat系Linux/MySQL : 5.0.27-0vl6。</p>
<p><strong>シチュエーション:</strong><br />
ある日、突然データベースがぶっとんでしまった(’A`)、ので、<br />
数日前に取っておいた全体バックアップとリアルタイムで更新される<br />
バイナリログを使用してデータベースを復旧させる。</p>
<p>●まず、定期的にデータベースの全体バックアップ（権限テーブル含む。<br />
# mysqldump &#45;&#45;user=root &#45;&#45;password=rootpass &#45;&#45;socket=/var/lib/mysql/mysql.sock<br />
&#45;&#45;single-transaction &#45;&#45;master-data=2 &#45;&#45;flush-logs &#45;&#45;hex-blob<br />
&#45;&#45;default-character-set=binary &#45;&#45;add-drop-table &#45;&#45;all-databases &gt; mysql-all.dump</p>
<p>（InnoDB以外のテーブルが含まれている場合は、共有ロックをかけるために<br />
&#45;&#45;single-transactionをはずしましょう。</p>
<p>（&#45;&#45;flush-logsでバックアップと同時にbin-logもスイッチされる。<br />
（/var/lib/mysqlにmysql-bin.000009が生成された</p>
<p><strong>データベースが飛んだ・・・・・(’A`)</strong></p>
<p>●Webアプリがデータベースを更新しないようにapacheをストップ<br />
# service apache2 stop</p>
<p>●MySQLをストップ<br />
# service mysql stop</p>
<p>●リストア、リカバリ時にバイナリログを生成しないように<br />
my.cnfのlog-bin=mysql-binをコメントアウト<br />
#log-bin=mysql-bin</p>
<p>●リモートから接続できなくするため&#45;&#45;skip-networkingオプションでmysql起動<br />
# /usr/bin/mysqld_safe &#45;&#45;defaults-file=/etc/my.cnf &#45;&#45;skip-networking &#45;&#45;skip-grant-tables &amp;<br />
[1] 28450<br />
# Starting mysqld-max daemon with databases from /var/lib/mysql</p>
<p>●全体バックアップからリストア<br />
# mysql &#45;&#45;user=root &#45;&#45;socket=/var/lib/mysql/mysql.sock<br />
&#45;&#45;default-character-set=binary &lt; mysql-all.dump</p>
<p>●バイナリログでリカバリ<br />
（全体バックアップ時に新たに生成されたmysql-bin.000009～を使う。<br />
# mysqlbinlog &#45;&#45;disable-log-bin /var/lib/mysql/mysql-bin.000009 &gt; recover.sql<br />
# mysql &#45;&#45;user=root &#45;&#45;password=rootpass &#45;&#45;socket=/var/lib/mysql/mysql.sock<br />
&#45;&#45;default-character-set=binary &lt; recover.sql</p>
<p>●my.cnfのlog-bin=mysql-binを有効にする<br />
log-bin=mysql-bin</p>
<p>●MySQL再起動<br />
# service mysql stop</p>
<p># service mysql start</p>
<p>これでＯＫ＾＾</p>
<p>かな？</p>
]]></content:encoded>
			<wfw:commentRss>http://sabakan.org/p/blog/2009/01/12/mysql%e3%81%ae%e3%83%90%e3%83%83%e3%82%af%e3%82%a2%e3%83%83%e3%83%97%ef%bc%86%e3%83%aa%e3%82%b9%e3%83%88%e3%82%a2%ef%bc%86%e3%83%aa%e3%82%ab%e3%83%90%e3%83%aa/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

