<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress/2.0.11" -->
<rss version="2.0" 
	xmlns:content="http://purl.org/rss/1.0/modules/content/">
<channel>
	<title>Comments on: MySQL 備份 shell script</title>
	<link>http://www.real-blog.com/linux-bsd-notes/125</link>
	<description>關於 PHP, Linux, Open Source 及個人生活記載的網誌。</description>
	<pubDate>Fri, 16 May 2008 20:16:21 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.0.11</generator>

	<item>
		<title>by: rice</title>
		<link>http://www.real-blog.com/linux-bsd-notes/125#comment-8125</link>
		<pubDate>Thu, 20 Mar 2008 06:16:14 +0000</pubDate>
		<guid>http://www.real-blog.com/linux-bsd-notes/125#comment-8125</guid>
					<description>我把程式抓下來直接在 Linux 上執行, 卻發生 common not found 之類的錯誤訊息, 後來我用筆記本開啟原檔案然後再開 vi 貼上, 就可以執行了 ...</description>
		<content:encoded><![CDATA[<p>我把程式抓下來直接在 Linux 上執行, 卻發生 common not found 之類的錯誤訊息, 後來我用筆記本開啟原檔案然後再開 vi 貼上, 就可以執行了 &#8230;
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: hodraw</title>
		<link>http://www.real-blog.com/linux-bsd-notes/125#comment-8124</link>
		<pubDate>Thu, 20 Mar 2008 04:29:08 +0000</pubDate>
		<guid>http://www.real-blog.com/linux-bsd-notes/125#comment-8124</guid>
					<description>例如在  /root 底下
&#62;  vi .my.cnf
加入
[client]
host=localhost
user=root
password=password

然後
&#62;  chmod 600 .my.cnf
(限制只有 root 能存取)

然後把 mysql_backup.sh 裡面的

db_user="root"
db_passwd=""
db_host="localhost"

這三行移除

all_db="$($MYSQL -u $db_user -h $db_host -p$db_passwd -Bse 'show databases')"
改成
all_db="$($MYSQL -Bse 'show databases')"


$MYSQLDUMP -u $db_user -h $db_host -p$db_passwd $db &#124; $GZIP -9 &#62; "$backup_dir/backup.0/$time.$db.gz"
改成
$MYSQLDUMP $db &#124; $GZIP -9 &#62; "$backup_dir/backup.0/$time.$db.gz"

這樣就預設就會去讀取 /root/.my.cnf 裡面的host、user、passwd 了</description>
		<content:encoded><![CDATA[<p>例如在  /root 底下<br />
&gt;  vi .my.cnf<br />
加入<br />
[client]<br />
host=localhost<br />
user=root<br />
password=password</p>
<p>然後<br />
&gt;  chmod 600 .my.cnf<br />
(限制只有 root 能存取)</p>
<p>然後把 mysql_backup.sh 裡面的</p>
<p>db_user=&#8221;root&#8221;<br />
db_passwd=&#8221;"<br />
db_host=&#8221;localhost&#8221;</p>
<p>這三行移除</p>
<p>all_db=&#8221;$($MYSQL -u $db_user -h $db_host -p$db_passwd -Bse &#8217;show databases&#8217;)&#8221;<br />
改成<br />
all_db=&#8221;$($MYSQL -Bse &#8217;show databases&#8217;)&#8221;</p>
<p>$MYSQLDUMP -u $db_user -h $db_host -p$db_passwd $db | $GZIP -9 &gt; &#8220;$backup_dir/backup.0/$time.$db.gz&#8221;<br />
改成<br />
$MYSQLDUMP $db | $GZIP -9 &gt; &#8220;$backup_dir/backup.0/$time.$db.gz&#8221;</p>
<p>這樣就預設就會去讀取 /root/.my.cnf 裡面的host、user、passwd 了
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: hodraw</title>
		<link>http://www.real-blog.com/linux-bsd-notes/125#comment-8123</link>
		<pubDate>Thu, 20 Mar 2008 03:49:02 +0000</pubDate>
		<guid>http://www.real-blog.com/linux-bsd-notes/125#comment-8123</guid>
					<description>crontab 執行這個 shell script時
當您用一般使用者打入
ps -aux
您的密碼就被看光光了

請參考官方的密碼安全設定修改
http://dev.mysql.com/doc/refman/5.1/en/password-security.html</description>
		<content:encoded><![CDATA[<p>crontab 執行這個 shell script時<br />
當您用一般使用者打入<br />
ps -aux<br />
您的密碼就被看光光了</p>
<p>請參考官方的密碼安全設定修改<br />
<a href="http://dev.mysql.com/doc/refman/5.1/en/password-security.html" rel="nofollow">http://dev.mysql.com/doc/refman/5.1/en/password-security.html</a>
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Sam Tang</title>
		<link>http://www.real-blog.com/linux-bsd-notes/125#comment-8070</link>
		<pubDate>Mon, 03 Dec 2007 05:04:05 +0000</pubDate>
		<guid>http://www.real-blog.com/linux-bsd-notes/125#comment-8070</guid>
					<description>假如你的資料庫名稱為 my_database，以下是還原方法:

1. 用 gzip 解壓備份檔，例如 gzip -d my_database.gz
2. 輸入以下指令:

mysql my_database -uroot -p &lt; my_database.sql

然後輸入 mysql 的 root 密碼。</description>
		<content:encoded><![CDATA[<p>假如你的資料庫名稱為 my_database，以下是還原方法:</p>
<p>1. 用 gzip 解壓備份檔，例如 gzip -d my_database.gz<br />
2. 輸入以下指令:</p>
<p>mysql my_database -uroot -p < my_database.sql</p>
<p>然後輸入 mysql 的 root 密碼。
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Takuya</title>
		<link>http://www.real-blog.com/linux-bsd-notes/125#comment-8069</link>
		<pubDate>Mon, 03 Dec 2007 04:13:36 +0000</pubDate>
		<guid>http://www.real-blog.com/linux-bsd-notes/125#comment-8069</guid>
					<description>想請教一下，關於10樓和12樓討論到備份的問題，可不可以說的再詳細一點，我還是不太懂要如何做，可否用站長所提供sh備份後的資料來做說明，謝謝</description>
		<content:encoded><![CDATA[<p>想請教一下，關於10樓和12樓討論到備份的問題，可不可以說的再詳細一點，我還是不太懂要如何做，可否用站長所提供sh備份後的資料來做說明，謝謝
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: youngten</title>
		<link>http://www.real-blog.com/linux-bsd-notes/125#comment-8002</link>
		<pubDate>Thu, 06 Sep 2007 23:50:20 +0000</pubDate>
		<guid>http://www.real-blog.com/linux-bsd-notes/125#comment-8002</guid>
					<description>我的問題跟 14 gary 一樣

請問站長大大，我想延續第六個問題。
就是您不是使用which mysql來當做mysql絕對路徑嗎，我在console下的確可以抓的到mysql絕對路徑，
可是為何放到crontab就不行呢？

感謝站長的熱心 

Comment by Gary — December 3, 2006 @ 10:58 am</description>
		<content:encoded><![CDATA[<p>我的問題跟 14 gary 一樣</p>
<p>請問站長大大，我想延續第六個問題。<br />
就是您不是使用which mysql來當做mysql絕對路徑嗎，我在console下的確可以抓的到mysql絕對路徑，<br />
可是為何放到crontab就不行呢？</p>
<p>感謝站長的熱心 </p>
<p>Comment by Gary — December 3, 2006 @ 10:58 am
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Sam Tang</title>
		<link>http://www.real-blog.com/linux-bsd-notes/125#comment-8001</link>
		<pubDate>Thu, 06 Sep 2007 14:11:11 +0000</pubDate>
		<guid>http://www.real-blog.com/linux-bsd-notes/125#comment-8001</guid>
					<description>看上面的回應:

試試將 $MYSQLDUMP 及 $MYSQL 改成你主機上面 mysqldump 及 mysql 的絕對路徑。

另外，Access denied for use 是 mysql 用戶的權限問題。</description>
		<content:encoded><![CDATA[<p>看上面的回應:</p>
<p>試試將 $MYSQLDUMP 及 $MYSQL 改成你主機上面 mysqldump 及 mysql 的絕對路徑。</p>
<p>另外，Access denied for use 是 mysql 用戶的權限問題。
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: youngten</title>
		<link>http://www.real-blog.com/linux-bsd-notes/125#comment-8000</link>
		<pubDate>Wed, 05 Sep 2007 18:17:25 +0000</pubDate>
		<guid>http://www.real-blog.com/linux-bsd-notes/125#comment-8000</guid>
					<description>1.本以為都OK了，結果用crontab 還是不行，原因應該還是一樣，因為我找不到 mysql log 所以也無法確定，

2.直接RUN不用crontab 到是可以

3.Access denied for user ‘user’@'localhost’ to database ‘information_schema’ when using LOCK TABLES</description>
		<content:encoded><![CDATA[<p>1.本以為都OK了，結果用crontab 還是不行，原因應該還是一樣，因為我找不到 mysql log 所以也無法確定，</p>
<p>2.直接RUN不用crontab 到是可以</p>
<p>3.Access denied for user ‘user’@&#8217;localhost’ to database ‘information_schema’ when using LOCK TABLES
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: youngten</title>
		<link>http://www.real-blog.com/linux-bsd-notes/125#comment-7999</link>
		<pubDate>Wed, 05 Sep 2007 15:04:34 +0000</pubDate>
		<guid>http://www.real-blog.com/linux-bsd-notes/125#comment-7999</guid>
					<description>resolved

1.我試過備份30天，it works
2.using single transaction could handle this problem
3.thanks</description>
		<content:encoded><![CDATA[<p>resolved</p>
<p>1.我試過備份30天，it works<br />
2.using single transaction could handle this problem<br />
3.thanks
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: youngten</title>
		<link>http://www.real-blog.com/linux-bsd-notes/125#comment-7998</link>
		<pubDate>Wed, 05 Sep 2007 03:38:27 +0000</pubDate>
		<guid>http://www.real-blog.com/linux-bsd-notes/125#comment-7998</guid>
					<description>大大謝謝你的回答，我用你的程式執行，出現以下訊息，不知該如何解決，壓縮有成功 information_schema 資料是空白，再次謝謝！

mysqldump: Got error: 1044: Access denied for user 'user'@'localhost' to database 'information_schema' when using LOCK TABLES</description>
		<content:encoded><![CDATA[<p>大大謝謝你的回答，我用你的程式執行，出現以下訊息，不知該如何解決，壓縮有成功 information_schema 資料是空白，再次謝謝！</p>
<p>mysqldump: Got error: 1044: Access denied for user &#8216;user&#8217;@'localhost&#8217; to database &#8216;information_schema&#8217; when using LOCK TABLES
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Sam Tang</title>
		<link>http://www.real-blog.com/linux-bsd-notes/125#comment-7997</link>
		<pubDate>Wed, 05 Sep 2007 02:37:59 +0000</pubDate>
		<guid>http://www.real-blog.com/linux-bsd-notes/125#comment-7997</guid>
					<description>將以下一行的 5 改成想要備份的日數:

test -d &#34;$backup_dir/backup.5/&#34; &#038;& $RM -rf &#34;$backup_dir/backup.5&#34;

例如 7 天便改成:

test -d &#34;$backup_dir/backup.7/&#34; &#038;& $RM -rf &#34;$backup_dir/backup.7&#34;

以及將以下一行修改，例如 7 天，便這樣:

for int in 6 5 4 3 2 1 0

以上改動我沒有測試過，記得測試一下才拿來用喔。</description>
		<content:encoded><![CDATA[<p>將以下一行的 5 改成想要備份的日數:</p>
<p>test -d &quot;$backup_dir/backup.5/&quot; &#038;&#038; $RM -rf &quot;$backup_dir/backup.5&quot;</p>
<p>例如 7 天便改成:</p>
<p>test -d &quot;$backup_dir/backup.7/&quot; &#038;&#038; $RM -rf &quot;$backup_dir/backup.7&quot;</p>
<p>以及將以下一行修改，例如 7 天，便這樣:</p>
<p>for int in 6 5 4 3 2 1 0</p>
<p>以上改動我沒有測試過，記得測試一下才拿來用喔。
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: youngten</title>
		<link>http://www.real-blog.com/linux-bsd-notes/125#comment-7996</link>
		<pubDate>Wed, 05 Sep 2007 01:22:46 +0000</pubDate>
		<guid>http://www.real-blog.com/linux-bsd-notes/125#comment-7996</guid>
					<description>如何把備份 5 天 改成更多天，謝謝大大！</description>
		<content:encoded><![CDATA[<p>如何把備份 5 天 改成更多天，謝謝大大！
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: gage</title>
		<link>http://www.real-blog.com/linux-bsd-notes/125#comment-7959</link>
		<pubDate>Sat, 07 Jul 2007 08:56:16 +0000</pubDate>
		<guid>http://www.real-blog.com/linux-bsd-notes/125#comment-7959</guid>
					<description>很棒的shell script，
對我有很大的幫助^^
超感謝！</description>
		<content:encoded><![CDATA[<p>很棒的shell script，<br />
對我有很大的幫助^^<br />
超感謝！
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Sam Tang</title>
		<link>http://www.real-blog.com/linux-bsd-notes/125#comment-7954</link>
		<pubDate>Sat, 30 Jun 2007 02:49:22 +0000</pubDate>
		<guid>http://www.real-blog.com/linux-bsd-notes/125#comment-7954</guid>
					<description>這個 shell script 的第一行是:

#!/bin/sh

這一行告訴系統 /bin/sh 用作解譯 shell script 內的指令，所以要確定你的系統是否有安裝 sh 這個 shell。</description>
		<content:encoded><![CDATA[<p>這個 shell script 的第一行是:</p>
<p>#!/bin/sh</p>
<p>這一行告訴系統 /bin/sh 用作解譯 shell script 內的指令，所以要確定你的系統是否有安裝 sh 這個 shell。
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Tom</title>
		<link>http://www.real-blog.com/linux-bsd-notes/125#comment-7953</link>
		<pubDate>Fri, 29 Jun 2007 09:43:41 +0000</pubDate>
		<guid>http://www.real-blog.com/linux-bsd-notes/125#comment-7953</guid>
					<description>你好，我將你的程式改寫，結果可以使用，很方便～但是有天我重慣FC4，結果同樣的程式執行，他卻說
『:bad interpreter:沒有此一檔案或目錄』，但是我可以很確定有該檔案，不知道是那邊出問題，希望你能解答～</description>
		<content:encoded><![CDATA[<p>你好，我將你的程式改寫，結果可以使用，很方便～但是有天我重慣FC4，結果同樣的程式執行，他卻說<br />
『:bad interpreter:沒有此一檔案或目錄』，但是我可以很確定有該檔案，不知道是那邊出問題，希望你能解答～
</p>
]]></content:encoded>
				</item>
</channel>
</rss>
