Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I'm using velosurf with MySQL on a Mac, without any encoding problems, but when I switch to a Linux machine, the values I get from velosurf are not encoded correctly.

I found out it might be a problem with the default connection character set. On the Mac I got:

mysql> show variables like "collation_%";
+----------------------+-------------------+
| Variable_name        | Value             |
+----------------------+-------------------+
| collation_connection | utf8_general_ci   |
| collation_database   | utf8_general_ci   |
| collation_server     | latin1_swedish_ci |
+----------------------+-------------------+
3 rows in set (0.00 sec)

mysql> show variables like "character_set_%";
+--------------------------+--------------------------------------------------------+
| Variable_name            | Value                                                  |
+--------------------------+--------------------------------------------------------+
| character_set_client     | utf8                                                   |
| character_set_connection | utf8                                                   |
| character_set_database   | utf8                                                   |
| character_set_filesystem | binary                                                 |
| character_set_results    | utf8                                                   |
| character_set_server     | latin1                                                 |
| character_set_system     | utf8                                                   |
| character_sets_dir       | /usr/local/mysql-5.5.11-osx10.6-x86_64/share/charsets/ |
+--------------------------+--------------------------------------------------------+
8 rows in set (0.00 sec)

While on the linux machine, I have:

mysql> show variables like 'collation_%';
+----------------------+-------------------+
| Variable_name        | Value             |
+----------------------+-------------------+
| collation_connection | latin1_swedish_ci | 
| collation_database   | utf8_general_ci   | 
| collation_server     | latin1_swedish_ci | 
+----------------------+-------------------+
3 rows in set (0.00 sec)

mysql> show variables like 'character_set_%';
+--------------------------+----------------------------+
| Variable_name            | Value                      |
+--------------------------+----------------------------+
| character_set_client     | latin1                     | 
| character_set_connection | latin1                     | 
| character_set_database   | utf8                       | 
| character_set_filesystem | binary                     | 
| character_set_results    | latin1                     | 
| character_set_server     | latin1                     | 
| character_set_system     | utf8                       | 
| character_sets_dir       | /usr/share/mysql/charsets/ | 
+--------------------------+----------------------------+
8 rows in set (0.00 sec)

The database collation and character set are set when I create the database. My problem is that I can't change the default character sets for the client/connection/results.

Also, there doesn't seem to be any way to set the charset with velosurf when the connection is initiated.

Any suggestions?

share|improve this question
2  
set names utf8; –  Imre L Jun 15 '11 at 10:45

2 Answers 2

There's a command line flag for MySQL to set character set. You could try that? --default-character-set=utf8

share|improve this answer
    
That might be what he's talking about, and --default-character-set=utf8 does not seem to override the character set defined in .ini / .cnf. I don't even have a .ini for my Windows MariaDB installation, and --default-character-set=utf8 won't override the default of latin1. –  JohnB Mar 25 '12 at 16:15
up vote 0 down vote accepted

I found out that MySQL will always use the default character set when connecting as root. But it works OK for limited users (something I should have been doing from the beginning).

This "feature" seems to be Linux specific. At least it doesn't happen in OS X.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.