Bug #103332 Can't open configuration file due to UnicodeDecodeError
Submitted: 15 Apr 2021 12:55 Modified: 8 Sep 2021 12:34
Reporter: Henning Schmidt Email Updates:
Status: Duplicate Impact on me:
None 
Category:MySQL Workbench Severity:S2 (Serious)
Version:8.0 OS:Windows
Assigned to: CPU Architecture:x86
Tags: my.ini, unicodeDecodeError

[15 Apr 2021 12:55] Henning Schmidt
Description:
I installed mysql 8.0 on a fresh Win Server 2019. After installation I'm not able to open the Servers Option File (my.ini).

Error: Error opening configuration file. UnicodeDecodeError: 'charmap' codec can't be decoded byte 0x9d in position 4292: character maps to <undefined>. 

I have never touched the my.ini in any way.

How to repeat:
German Windows Server 2019. Fresh Install.
[15 Apr 2021 13:03] Henning Schmidt
Added information: I opened the configuration file with the workbench (Version 8.0 CE)
[15 Apr 2021 13:52] MySQL Verification Team
Check last comment from https://bugs.mysql.com/bug.php?id=95293. Thanks.
[15 Apr 2021 18:19] Henning Schmidt
That fixed my problem that I could not restart the service after editing the my.ini with the build-in Windows Editor (I saved the file as UNICODE, nevertheless it wasn't working after restarting, now used notepad++ and it's working fine). But I still can't access the option page in the workbench. 
Deinstalled the server, deleted all files, reinstalled mysql 8.0 -> Same error.
[19 Apr 2021 13:21] MySQL Verification Team
Hello Henning Schmidt,

Thank you for the bug report and feedback.
This might be fixed in WB 8.0.24, hence wait until 8.0.24 is out and try again. Thanks.

Regards,
Ashwini Patil
[13 May 2021 16:41] Lee Matthews
I have the same issue with MySQL Workbench 8.0.25.
UnicodeDecodeError: 'charmap' codec can't decode byte0x9d in position 4312: character maps to <undefined>
[20 May 2021 1:00] Bugs System
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
[7 Jun 2021 14:40] Renee La Forest
If you have changed the default location, check the permissions on the newly created folder.
[8 Sep 2021 9:04] Pieter Sadie
Just installed MySQL 8.0.25 on a new server
Immediately upgraded all components to 8.0.26 after install.

Tried to open Options File in Workbench but getting the error:
Cannot Open Configuration file
UnicodeDecode Error: 'charmap' codec can't decode byte 0x9d in position 4451: Character maps to <undefined>

Also, when trying to save the changes in the Options file, I get this error:
Error: Unhandled exception ('mysqld',)
[8 Sep 2021 10:17] Pieter Sadie
After doing some research I found the following:

https://bugs.mysql.com/bug.php?id=103750

and also
https://stackoverflow.com/questions/63433111/how-to-fix-the-error-unicodedecodeerror-charm...

They all mentioned "weird characters" in the file being the cause of the Unicode Decode error.

Just as a test, I deleted the entire comment section above the "server-id=" parameter

I closed WorkBench and re-opened it, and now it is able to open the Options File. 

However I am still unable to save the changes. Workbench says it is unable to write to C:\ProgramData\MySQL\MySQL Server 8.0\my.ini. 

But I just previewed the file and copied the changes and then made the changes using NotePad++ in Admin mode and that worked.

Clearly there are indeed some "weird characters" in the My.ini file that needs to be removed.
[8 Sep 2021 10:40] Pieter Sadie
I still kept getting the Unicode Decode error in WorkBench 8.0 version 26
I then noted the position of the character giving the error - for example 5724.

Using NotePad++ go to View, Show Symbol, Show All Symbols.
Then scroll down and find the character in that position (it shows the position of the cursor at the bottom).
In this case it turned out to be a CRLF character at that position.
I deleted it and pressed ENTER to create a new CRLF character and saved the file.
Closed Workbench and re-opened and it now opens the file again.

For Reference, I am using Windows 10 21H1 build 19043.1202
[8 Sep 2021 12:34] MySQL Verification Team
Hello,

Thank you for the feedback.
Imho this is duplicate of Bug #104365, please see Bug #104365.

Regards,
Ashwini Patil
[20 Oct 2021 22:49] ruud pols
I finally solved this issue by opening my.ini with notepad++ and converting the encoding from utf8 to ansi...  Weird.
[10 May 3:55] Cees Kettenis
Hello,

I encountered the same issue.

I freshly installed MySQL 8.0xx and when I went to open the my.ini in workbench I got the same error.

I managed to resolve my issue by opening my.ini and removing all the comments.

I think there is some weird character combination in there by accident.

I hope this helps someone
[10 May 11:53] MySQL Verification Team
Hi,

This bug is a duplicate of the several already verified bugs, including #104364.

You just have to follow when the original bugs are changed from "Verified" to "Closed".
[11 Aug 19:56] Mark Dodrill
Looks like the special char is a double quotes that is backwards from the normal orientation.  I found two instances in my.ini that needed to be fixed.
[12 Aug 14:48] Rik Clews
found the comments contain odd "smart quotes" e.g. “” these appear twice in my.ini  - on my version 8.0.30 at line 107 above "authentication_policy=caching_sha2_password,," is a comment: # definitions, where “factor” corresponds to an authentication method or plugin associated
and 
line 142 above "server-id=1" is another: # range from 1 to 2^32 − 1. “Unique” means that each ID must be different

I replaced these with "normal" double quotes and it opens ok now
[16 Aug 12:08] MySQL Verification Team
Thank you Mr. Clews.