1

When I make a query from the mysql console and it has accents or any character that needs to be utf-8 encoded, it gets mugged

INSERT INTO users (userName) VALUES ("José Alarcón");
SELECT userName FROM users;
José Alarcón

SET NAMES utF8 changes nothing --default-character-set=utf8 as parameter changes nothing Keep in mind than this is ONLY from the console. If I use phpmyadmin or make any query from a program, there is no problem at all, but an inserted row from the console gets muggled. I'm using putty on windows as client

~$ locale
LANG=en_US.UTF-8
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=

Clarification: Mi local computer is windows XP, i'm using putty 0.60 as terminal client. The target system where MySQL is running is a Debian linux I can't find any configuration in putty for character encoding...

Update: Stupid PuTTY, having the encoding configuration inside a menu called "translation" WTF?

The Disintegrator
  • 4,147
  • 9
  • 35
  • 43

3 Answers3

2

Set PuTTY to interpret received data as UTF8 in Window -> Translation "Character set on received data".

Alex Budovski
  • 17,947
  • 6
  • 53
  • 58
0

Windows can't handle UTF8 in console and system messages (which putty uses). It wants to use your locale codepage. This is a common and known problem, and it's not solvable without rewriting cmd.exe, or using a different command line tool.

Microsoft have never really bothered about encodings outside their own world, which results in weird windows specific codesets.

Maybe you can change the putty encoding somewhere in its options so that it can at least communicate correctly to the mysql cli?

Tor Valamo
  • 33,261
  • 11
  • 73
  • 81
0

Your terminal client must be configured using UTF8. Your shell environment on the server must also be configured as UTF8. You can check it out with the following command.

locale

It depends on the distribution (I'm assuming you are using linux) how the system prefers how you fix the locale information if needed. For instance, Debian (and, I guess, Ubuntu) ask you to use the following command to reconfigure the locale settings.

dpkg-reconfigure locales

Notice; I'm not sure if they've changed this, haven't tested it in a while. :-)

You can of course set the locales in the shell each time you log in or in your profile. I recommend that you use the distribution's method to do it (if you need to do it after all :-)).

  • Uhhh. He has never said so. He only said he's using putty on Windows as the console client. He never said if he's using MySQL on Windows, Linux, or what ever else. – Kristinn Örn Sigurðsson Jan 02 '10 at 01:38
  • And yes, please take that down vote off my answer since it has no right to be there, since after all, I did read the question carefully and he does not state that if he's connecting to a linux server or just connecting to a local MySQL server running on his Windows computer. – Kristinn Örn Sigurðsson Jan 02 '10 at 01:44
  • P.S. In the comment above, I meant that PuTTY is a terminal client, not a console client. :-) – Kristinn Örn Sigurðsson Jan 02 '10 at 01:52
  • Thanks for the up vote. :-P On other matters. What character set is PuTTY using? You are able to change it in the properties/preferences window. Unfortunately I don't have this in front of me. @Tor Valamo 's answer was only mentioning if you were using PuTTY as a command prompt for Windows. You are able to use PuTTY as a SSH client with UTF8 encoding. The MySQL results should be displayed correctly if your ssh client (PuTTY) is configured to use UTF8 encoding and your shell environment (server side) is configured as you pasted in your last edit of your question. – Kristinn Örn Sigurðsson Jan 02 '10 at 03:03
  • I was thinking that Putty didn't had a encoding configuration (never found it before). It turned out it was in the "translation" option, I always overlooked it, I though it was for running putty in a different language, not a different encoding... – The Disintegrator Jan 02 '10 at 03:14