This article was migrated from http://rails.office.drecom.jp/hibi/archive/15

永久って書き方がすごいですが。

アプリを動かしてると、

"Illegal mix of collations
(latin1_swedish_ci,IMPLICIT) and
(sjis_japanese_ci,COERCIBLE) for operation '='"

みたいなエラーが出て。文字コードはUTF8とswedishなんたらだったけど。
したら、take another stepさんが対決してはった。
http://dream.ie.ariake-nct.ac.jp/~naoyuki/archives/000041.php

つまり、サーバとクライアントのコードが違うということらしいです。
ふむ。

mysqlのリファレンスを調べる。したらコレ。
http://dev.mysql.com/doc/refman/5.0/en/charset-connection.html

SET NAMES 'x'

としたらいいらしい。
でもこれだとアプリで毎回しなくちゃいけないし。
大体rubyでどうするのかよくわからない。

そしたら!
先のmysqlのリファレンスのしたーーーのほうに
N Bernhardtさんがコメント。
--------------------------------------------------
Posted by N Bernhardt on August 17 2005 4:51pm

To change the connection charset permanently to UTF-8, add the following line in the [mysqld] section:
[mysqld]
init-connect='SET NAMES utf8'
--------------------------------------------------

で、/etc/mysql/my.cnfの[mysqld]のところにinit-…を追加しました。
show variables like 'character%';
show variables like 'collationr%';
してもやっぱり変数の値は変わってないですが、アプリを起動すると…
あら不思議!ちゃんと動きました!

(ただこれするとほかのアプリとかでUTF8にしたくないときも
UTF8になるので注意って書いてありました。なので注意です。)

とにかくやったーーー!
いやもうなんでも初心者で大変です。 http://rails.office.drecom.jp/hibi/archive/15

This article was migrated from http://rails.office.drecom.jp/hibi/archive/15

posted by Png satoko on Mon 5 Jun 2006 at 15:37

This article was migrated from http://rails.office.drecom.jp/hibi/archive/14

winのとよく似てます。

database.ymlのproductionのDB接続を編集

環境変数RAILS_ENVをセット。
export RAILS_ENV=production

script/aboutで確認
サービススタート!
lighttpd start -f lighttpd.myapp.conf -D

これでおっけー!
なんかあっけなかった。。。 http://rails.office.drecom.jp/hibi/archive/14

This article was migrated from http://rails.office.drecom.jp/hibi/archive/14

posted by Png satoko on Mon 5 Jun 2006 at 15:21
Contents
MYSQLへの接続を永久UTF8化:Illegal mix of collations 
今度はDebianでproduction 
Comments
瀧内元気: MacOS版は以下にあります * [genki/ViMouse](https://githu... '23-1
KingofSmack: Here also good reads for this mobile applicatio... '14-5
Spencer: You don't have to re-compile it, this version w... '14-4
staiano: Any chance we can get a recompile for 10.9? '14-1
dsjf: https://gist.github.com/6bf1bf2c3cbb5eb6e7a7 これ... '13-1
Services from s21g
twpro(ツイプロ)
Twitterプロフィールを快適検索
地価2009
土地の値段を調べてみよう
MyRestaurant
自分だけのレストラン手帳
Formula
ブログに数式を埋め込める数式コミュニティ