Cygwin + ck で Windows MySQL へログインすると文字化けに困らなくて済む
今まで DB の代わりにテキストファイルとか PStore を使って rails アプリを作っていたけど、そろそろ DB 使って組もうかと。
日頃は Cygwin + ck を使って rails アプリを組んでいたけど、Windows MySQL をインストールしてみた。が、接続できない・・・。Cygwin 用の MySQL ってあるんだっけ?と思いながらグーグル先生に聞いて見たところ
- config/database.yml のホストを localhost -> 127.0.0.1 に変更すれば rails からアクセスできる
- linux MySQL のソースを make & install(サーバ機能以外)すれば Cygwin からもアクセスできる
ことが分かった。ありがとう先駆者!
後者に関しては下記ページで
連絡拒否
書いてある通り、config から install までの時間が結構かかる・・・。CPUが常に100%だし。
前者で rails からのアクセスが成功したので、Cygwin からもログインしてみる
$ ./mysql -h 127.0.0.1 -u user -pxxxxxx Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 7 Server version: 5.0.45-community-nt MySQL Community Edition (GPL) Type 'help;' or '\h' for help. Type '\c' to clear the buffer. mysql> use sample_develop Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A Database changed mysql> select * from books; +----+-----------------------------+ id title +----+-----------------------------+ 1 aaaaaaaaa 2 あああああああああ 3 ①Ⅰ㍉㌔㌧〒―− +----+-----------------------------+ 3 rows in set (0.00 sec)
キタ━━━━ヽ(゚∀゚ )ノ━━━━!!!!
MySQLインストール時にUTF8を指定したのに、ここでなにげに文字化けしていないのがポイント。ck で UTF8を表示時のエンコード指定の一つに追加しておけばいいだけ。ありがとう ck ! good-job !