經常要在shell下查詢數據庫的東西,數據庫有中文,shell顯示就是亂碼,有幾個方法看看結果首先linux中文字體要安裝,這個自己裝,數據庫的字符集要支持中文,我的支持啊,然后就是在寫shell的時候的問題了
mysql -u root -p --default-character-set=utf8 db -e "select * from tb where A=10;"
這個顯示的就是亂碼
mysql -u root -p db -e "set names utf8 ;select * from tb where A=10;"
這個還是亂碼
mysql -u root -p db -e "set names Latin1 ;select * from tb where A=10;"
這個也是亂碼
mysql -u root -p db -e "set names gbk ;select * from tb where A=10;"
最后這個卻顯示中文了!!!!
http://wdegang.blog.51cto.com/134120/1137929