Bug #104509 MySQL fails to start if my.ini file is encoded as UTF-8-BOM
Submitted: 2 Aug 2021 19:00 Modified: 8 Sep 2021 13:10
Reporter: Sergio Henrique Email Updates:
Status: Duplicate Impact on me:
None 
Category:MySQL Server: Windows Severity:S3 (Non-critical)
Version:8.0.26 OS:Windows (Server 2019 Standard)
Assigned to: CPU Architecture:x86

[2 Aug 2021 19:00] Sergio Henrique
Description:
If the my.ini file is encoded as UTF-8-BOM instead of UTF-8, the service will fail to start. Furthermore, Microsoft Notepad quietly saves the file as UTF-8-BOM, even if there was no modification.

How to repeat:
1. Install a fresh copy of Windows Server 2019 Standard Edition.
2. Install MySQL (the latest version at the time of writing is 2.0.26).
3. Open my.ini in Microsoft Notepad, then click File, then Save.
4. Restart MySQL service.

Suggested fix:
MySQL service would be more resilient if it read the my.ini file even if it was in UTF-8-BOM encoding.
[8 Sep 2021 13:10] MySQL Verification Team
Hello Sergio Henrique,

Thank you for the bug report.
Imho this is duplicate of Bug #95293, please see Bug #95293.

Regards,
Ashwini Patil
[8 Sep 2021 13:11] MySQL Verification Team
Quoting a note from https://dev.mysql.com/doc/refman/8.0/en/charset-unicode.html

"MySQL uses no BOM for UTF-8 values. "
[29 Jun 2023 7:59] Stefano Rocca
In the last few months I stumbled upon this issue a couple of times.
It is a duplicate of Bug #95293 but here the problem is stated clearly and also the affected version of MySQL is more up to date (it happens also on MySQL 8.0.33).
Please note that it is really hard to find the problem because:

1. MySQL does not write the error log (because MySQL cannot read the my.ini at all)
2. the manual does not warn about the BOM in the my.ini

I suggest (1) to add a warning to this page

https://dev.mysql.com/doc/mysql-windows-excerpt/8.0/en/windows-troubleshooting.html

and, of course, (2) to fix this problem in MySQL.

The only way MySQL communicates that there is a problem in my.ini is by running it from the command line adding the --console switch:

"C:\Program Files\MySQL\MySQL Server 8.0\bin\mysqld.exe" --defaults-file="C:\ProgramData\MySQL\MySQL Server 8.0\my.ini" --console MySQL80