All_about_network

Mysql and utf8

by tnk on Oct.08, 2008, under Linux, Software

mysql_logoAs time passed I encountered an very strange behaviour of phomyadmin – all tables were created in Swedish language by default which is not very useful when all your application are written to use utf8. I made some digging around the web and found following information

  1. My first thoughts were that the problem with misinterpreted characters in phpmyadmin were only problem of the web-interface setting (but even after several dozens minutes of playing with this I had no results)
  2. So after this fruitless operation I realized there is something wrong with the underlying layer – with the mysql itself. So the next step was to check up on the database. The only valid thing I was able to get from the mysql docs was a command ” SET NAMES” which does a small miracle it sets everything client, server etc. to communicate in whatever charset you want, BUT it is temporary. Whenever you restart your mysqld this setting is gone and the one from /etc/mysql/my.cf is loaded again.
  3. So my step number three was to edit directly my.cf (actually I did that at the beginning but it was not working due to my misconfiguration). After editing the my.cf I was actually able to set all the new databases and client communications to utf8.

And how this miraculous piece of code looks like ?

[client]

default-character-set=utf8

[mysqld]

default-character-set=utf8
default-collation=utf8_czech_ci

As far as I know this is the only solution and it is not mentioned anywhere on the web. The only useful link I did find and is also very close to the truth is this site about utf8 in mysql and php connection to it. You can find there more detailed information about this stuff.

:, ,

Leave a Reply

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!