Mysql – thesql: set default charset to utf8

charsetMySQL

In an effort to set the default charset for a MySQL server to utf8, I've added the following options to my.ini

character-set-server=utf8
default-collation=utf8_unicode_ci

But when I start the mysql client, I get the following error message:

error: Found option without preceding
group in config file:
C:\dev\tools\mysql\my.ini at line: 2
Fatal error in defaults handling.
Program aborted

Does anyone know what the right way to set the default charset in this config file is?

Best Answer

The problem the server complains about is that it can't find the expected INI section ([mysqld]) to which these settings belong. Ensure you've added those settings to the [mysqld] section, like this:

[mysqld]
character-set-server=utf8
default-collation=utf8_unicode_ci

If there's already such a section there, add your settings to to that section, don't create a duplicate section.

After altering the configuration file, restart the MySQL server.

Related Topic