1

Possible Duplicate:
UTF-8 all the way through

I am having some difficulty changing everything in a database to be utf8.

Here is what I currently have:

+--------------------------+----------------------------+
| Variable_name            | Value                      |
+--------------------------+----------------------------+
| character_set_client     | utf8                       |
| character_set_connection | utf8                       |
| character_set_database   | latin1                     |
| character_set_filesystem | binary                     |
| character_set_results    | utf8                       |
| character_set_server     | latin1                     |
| character_set_system     | utf8                       |
| character_sets_dir       | /usr/share/mysql/charsets/ |
| collation_connection     | utf8_general_ci            |
| collation_database       | latin1_swedish_ci          |
| collation_server         | latin1_swedish_ci          |
+--------------------------+----------------------------+

I have a /etc/my.cnf file with the following contents:

[client]
default-character-set=utf8

[mysql]
default-character-set=utf8


[mysqld]
init_connect='SET collation_connection = utf8_general_ci'
init_connect='SET NAMES utf8'
default-character-set=utf8
character-set-server=utf8
collation-server=utf8_general_ci
skip-character-set-client-handshake

When I do $ sudo service mysql restart to 'load' the files, nothing happens. How can I get everything utf8 here?

mysql> show variables like '%init_file%';
+---------------+-------+
| Variable_name | Value | 
+---------------+-------+
| init_file     |       |
+---------------+-------+
Community
  • 1
  • 1
David542
  • 104,438
  • 178
  • 489
  • 842
  • do `show variables like '%init_file%'` to confirm that there's no other .ini/.cnf file being loaded that could be overriding your changes. – Marc B Dec 04 '12 at 20:53
  • @MarcB I have updated it to show. – David542 Dec 04 '12 at 20:55
  • also, note you've got incorrect quotes in your pasted text: `init_connect=’SET`. `’` is not the same as `'`. Don't know if mysql cares, but you may want to check on that. – Marc B Dec 04 '12 at 20:58
  • @MarcB I made that change but that didn't seem to affect anything. It doesn't even appear to be reading the my.cnf file. – David542 Dec 04 '12 at 21:30
  • @Jack - that's a good question regarding utf, but doesn't even mention the `my.cnf` file (i.e., doing a search for 'my.cnf' in the file gives 0 results). – David542 Dec 04 '12 at 23:08
  • Btw, shouldn't `init_connect` be client related instead of server? – Ja͢ck Dec 04 '12 at 23:15

1 Answers1

1

I think your problem is in the fact you are using dashes and not underscores. I think dashes are meant for command line options whereas these are meant for my.cnf. And yes, this is helluva confusing!

The only utf8 references in my local Ubuntu my.cnf are:

[mysqld]
...
character_set_server = utf8         # you have character-set-server
collation_server = utf8_general_ci  # you have collation-server

Any my variables look like:

mysql> show variables like '%charac%';
+--------------------------+----------------------------+
| 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     | utf8                       |
| character_set_system     | utf8                       |
| character_sets_dir       | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+
mindas
  • 26,463
  • 15
  • 97
  • 154
  • Not entirely sure whether that's correct; according to the [manual](http://dev.mysql.com/doc/refman/5.0/en/server-options.html#option_mysqld_character-set-server) the dashes are okay in the config file. – Ja͢ck Dec 04 '12 at 23:11