Archive for category Linux
Install Mercurial on CentOS5
最近看大家都在換 scm,我心動就也想換 Mercurial,因為有好幾個平台要裝,一開始在 ubuntu 裝的時候,很簡單的
就可以了,簡單到後空翻。但是我換 CentOS 想用 yum 快速解決的時候,儼然發現 mercurial 不在 CentOS 的 packages 裡面,search 也 search 不到。
後來才發現原來 Mercurial 的官網就寫的很清楚了…
CentOS release 5 (final) – yum install mercurial from rpmforge repository, latest stable (1.0)
反正就是要 include source from rpmforge,這樣才會有 mercurial 可以裝:
首先要確認 priorities 已經裝好了,如果還沒:
然後要確定 yum-priorities 已經啟用,可以看 /etc/yum/pluginconf.d/priorities.conf 這個檔案裡是不是明確寫著 enabled=1,如果沒有的話就加上去,或是改成 1。
然後開始改 /etc/yum.repos.d/ 底下的 .repo 類型的檔案( 我是有兩個 ),加上各自的 priorities,官網 wiki 的建議設置如下:
[centosplus],[contrib] … priority=2
Third Party Repos such as rpmforge … priority=N (where N is > 10 and based on your preference)
然後去抓 http://apt.sw.be/redhat/el5/en/i386/RPMS.dag/rpmforge-release-0.3.6-1.el5.rf.i386.rpm ( rpmforge 的 rpm ) 回來,開始做以下的動作:
Install DAG’s GPG key
Verify the package you have downloaded
Install the package
This will add a yum repository config file and import the appropriate GPG keys. At this point, you can set the priority of the RPMForge repository, and also of the CentOS repositories if you have not done so yet.
Test with this command:
應該會 print 出…
…
76 packages excluded due to repository priority protections
然後應該就可以 yum install mercurial 了,打完收工。
ref: CentOS Wiki
Convert a MySQL DB from latin1 to UTF8
For work, I have to convert my very old database from latin1 based( with big5 in it ) to UTF8.
My Enviornment:
- OS: Gentoo
- Python: Python 2.4.3
- MySQL: MySQL 5.0.70-log Gentoo Linux mysql-5.0.70-r1
- Old encoding: latin1(big5)
- Try to convert to: UTF8
And here’s my solution, and memo.
Assume your private parameters as following:
- Your old db name: your_old_db
- Your new db name: your_new_db
- Your mysql account: your_db_acc
- Your mysql server’s ip or dn: your_db_host
mysqldump -u wwwuser -p –default-character-set=latin1 your_old_db > output.sql
# — fix origin output.sql’s big5 problem here ( do some regex replacement, it depends ) —
# convert the "real storage encoding" from "big5" to utf8, latin1 is just a tag note in db
piconv -f big5 -t utf8 output.sql > utf8.sql
# replace all charset and collate in sql file, and delete the line which include "SET NAMES latin1"
# for matching, the longer the better ex: match from "type=Mxxx….", you could do this from the beginning of each single line
sed -e ‘s/DEFAULT CHARSET=latin1/DEFAULT CHARSET=utf8/g’ -e ‘s/CHARSET=gbk/CHARSET=utf8/g’ -e ‘s/ collate gbk_bin//g’ -e ‘s/ COLLATE=gbk_bin//g’ -e ‘/SET NAMES latin1/d’ utf8.sql > utf8_after_sed.sql
# echo SET NAMES utf8 to a new file named tmp.sql
echo "SET NAMES utf8;" > tmp.sql
# merge the two files
cat utf8_after_sed.sql >> tmp.sql
# rename the file to utf_final.sql, just a clarify
mv tmp.sql utf8_final.sql
# import to a new unicode based db, we’re done here
mysql -h your_db_host -u your_db_acc -p –default_character_set utf8 your_new_db < utf8_ultimate.sql
Thanks sooooooo a lot for Tib‘s kindly provide his consultation.
Add Sudoer
這是個 FAQ 文,Linux 弱如本人,寫教學文好像不是什麼好主意,所以只是個 FAQ 文。
關於 Add sudoer 這件事…每個 OS 都不太一樣,我自己是比較會 CentOS/Ubuntu。 Read the rest of this entry »
Recent Comments