# Encoding-differences in mysql/ruby-bindings and mysql/native

**URL:** <https://www.ruby-forum.com/t/encoding-differences-in-mysql-ruby-bindings-and-mysql-native/100531>\
**Category:** Rails\
**Created:** [December 2, 2005, 2:38pm UTC](https://www.ruby-forum.com/t/encoding-differences-in-mysql-ruby-bindings-and-mysql-native/100531 "2005-12-02T14:38:00Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![JanPrill](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/f0a364/32.png) [@JanPrill](https://www.ruby-forum.com/u/JanPrill)\
**Post date:** [December 2, 2005, 2:38pm UTC](https://www.ruby-forum.com/t/encoding-differences-in-mysql-ruby-bindings-and-mysql-native/100531/1 "2005-12-02T14:38:00Z")

</div>

Hi, List,

after testing my current project on EdgeRails I’ve realised that the  
connections to mysql gets lost. This is while I’m on Windows Server  
2003, ruby 1.8.2 and EdgeRails. I’ve experienced these connection losses  
some time ago after updating to Rails 1.0rc4 and got around it by  
commenting out a line containing mysql411 in mysql\_adapert.rb. But this  
don’t seem to be the problem any longer in EdgeRails since this line  
isn’t present in the current mysql\_adapter.rb of trunk. So I decided to  
give the native-mysql bindings another try. Something I gave up on the  
last time I’ve experienced this problem because of the difficulties that  
are coming with the compiling of mysql-2.7 on windows. Anyway: This time  
I’ve compiled my own version of mysql.so and also tried the one that  
comes with “Ruby on Apache”.

My problem now is that connection to mysql works again, but while I’m  
retrieving, updating or inserting records to mysql 5.0 tables with  
encoding of utf-8 my actions result in incorrect encodings. Accented  
characters and other special characters are broken because of this. The  
mysql/ruby-bindings didn’t have this problem. Has anyone run into this  
and could give me a clue what is going on here?

Regards  
Jan P.

---

<div class="post-metadata">

**Author:** ![JanPrill](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/f0a364/32.png) [@JanPrill](https://www.ruby-forum.com/u/JanPrill)\
**Post date:** [December 2, 2005, 3:22pm UTC](https://www.ruby-forum.com/t/encoding-differences-in-mysql-ruby-bindings-and-mysql-native/100531/2 "2005-12-02T15:22:57Z")

</div>

Hi List,

just to answer my own question:

After adding encoding: utf8 (# NOT utf-8 or UTF-8) to  
config/database.yml the encoding-problems are gone with the wind. And  
guess what: Running on EdgeRails and mysql-native-bindings seems to  
result in a 300-400% performance increase in development mode. Most of  
it would be the native-bindings I guess. This is no news for the readers  
of rubyonrails weblog, but for me it’s a great improvement as I’ve  
managed to get it working for the first time on windows without the  
encoding-problems.

Regards  
Jan

---

<div class="post-metadata">

**Author:** ![JanPrill](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/f0a364/32.png) [@JanPrill](https://www.ruby-forum.com/u/JanPrill)\
**Post date:** [December 2, 2005, 4:19pm UTC](https://www.ruby-forum.com/t/encoding-differences-in-mysql-ruby-bindings-and-mysql-native/100531/3 "2005-12-02T16:19:54Z")

</div>

On 2-dec-2005, at 14:37, Jan P. wrote:

> bindings another try. Something I gave up on the last time I’ve  
> anyone run into this and could give me a clue what is going on here?  
> I am running two apps on edge rails on OS X and FreeBSD, with MySQL  
> 4.1 and everything works fine (both apps are in Russian).  
> Are you sure you got your tables, columns et al CHARSET’ted properly?  
> Are you sure that you have your encoding set up as utf8 in the  
> database.yml? (no dashes?)

However I use my own legacy plug-in to configure the charset.

If so, it ought to be something with the 5.0 branch.

---

<div class="post-metadata">

**Author:** ![JanPrill](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/f0a364/32.png) [@JanPrill](https://www.ruby-forum.com/u/JanPrill)\
**Post date:** [December 2, 2005, 4:23pm UTC](https://www.ruby-forum.com/t/encoding-differences-in-mysql-ruby-bindings-and-mysql-native/100531/4 "2005-12-02T16:23:58Z")

</div>

On 2-dec-2005, at 15:19, Jan P. wrote:

> Hi List,
> 
> just to answer my own question:
> 
> After adding encoding: utf8 (# NOT utf-8 or UTF-8) to config/  
> database.yml the encoding-problems are gone with the wind.

So I was right on that one. Glad you got it sorted out.  
Actually this ought to raise an exception of MySQL can’t configure  
the charset, I will look at the sources.
