Bug #67880 mysql 5.6.9 on windows does not start if my.ini file is in utf8 format
Submitted: 12 Dec 2012 1:20 Modified: 12 Dec 2012 5:17
Reporter: Franjo Markovic Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: Installing Severity:S1 (Critical)
Version:5.6.9 OS:Microsoft Windows
Assigned to: CPU Architecture:Any

[12 Dec 2012 1:20] Franjo Markovic
Description:
G:\Users\Franjo>mysql_upgrade
error: Found option without preceding group in config file: G:\Program Files\MySQL\MySQL Server 5.6\my.ini at line: 1
Fatal error in defaults handling. Program aborted

G:\Users\Franjo>mysqld
error: Found option without preceding group in config file: G:\Program Files\MySQL\MySQL Server 5.6\my.ini at line: 1
Fatal error in defaults handling. Program aborted

How to repeat:
change my.ini file to be in utf8 format and try to start the server

Suggested fix:
support utf8 format of my.ini
[12 Dec 2012 7:47] Erlend Dahl
We have looked at this. It's unlikely that it has ever worked properly to have a my.ini file in utf-8.
[12 Dec 2012 10:50] Peter Laursen
I have reported same/similar 3-4 years ago.  The bug report was closed with a documentation update.
[12 Dec 2012 11:45] Hartmut Holzgraefe
Is this really about UTF8 encoding? What non-ASCII characters would show up in a my.cnf anyway?

Isn't this actually about the bad habit of some Windows editors to put a Byte Order Mark (BOM) at the beginning of UTF8 encoded files even though that is totally redundant with UTF8?

PS: there are other BOM related bugs filed for other areas of MySQL, e.g. bug #10573 and #65537 ...
[12 Dec 2012 12:13] Peter Laursen
@Hartmut!

BOM's are not redundant with UTF8 on Windows. They are required outside the ASCII-range (æ, ä etc.). Windows assumes text files without BOM's to be ANSI-encoded. Windows will try to use ANSI/non-unicode as long as it can be done without loss. However if you specify (in 'Notepad' 'save as' dialog for instance) UTF8 as the encoding BOMs will be added - also as long as only characters from a single codepage exist in the file. "Save as UTF8" in Windows means "force BOMs".

Windows reads files without BOM's as ANSI. To read it as UTF8 you must use BOMs. If not characters like æ, ä etc. in an UTF8 file will be read as 2 single-byte characters and not as multibyte characters.

(and I tried to find my old bug report about same, but no luck.  But conclusion is that UTF8 will only work in my.ini if content is pure ASCII and without BOMs)
[12 Dec 2012 12:30] Peter Laursen
Hooray!

Here is my old bug report about same:
http://bugs.mysql.com/bug.php?id=43273
[12 Dec 2012 12:36] Peter Laursen
.. and @Hartmut. Discuss Windows with your colleague Vladislav Vaintrub - he understands problems, issues and limitations with MySQL on Windows better than anyone else ;-)
[9 Jun 2020 6:36] lau ho
I also encounter similar in MySQL 8.0.20 in Microsoft Windows Platform.
I have edited my.ini in Microsoft Notepad and the Notepad change the file encoding to UTF-BOM.

The MySQL 8 instance could not be started if the "my.ini" is UTF8 encoding with BOM.