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 2022 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 2022 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 2022 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 2022 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 2022 12:08] MySQL Verification Team
Thank you Mr. Clews.
[13 Dec 2022 12:04] Ahmed Bsher
Many thanks  Rik Clews
[13 Dec 2022 12:36] MySQL Verification Team
Hi Mr. Clews,

This is considered a nice little contribution for the documentation of our Workbench options.

Thank you .....
[25 Jan 2023 11:12] Raimonds Linde
2023! MySql Workbench still can't process Unicode double-quotes like “factor”.
[28 Feb 2023 17:48] Austin Webber
Can confirm this is still an issue as of 2/28/2023. Here was my message log when configuring local management:

Check if C:\ProgramData\MySQL\MySQL Server 8.0\my.ini can be accessed
File was found at the expected location
Check if section for instance mysqld exists in C:\ProgramData\MySQL\MySQL Server 8.0\my.ini
Operation failed: error calling Python module function WbAdmin.testInstanceSettingByName

To fix this I had to remove all instances of smart quotes (“”) from my my.ini file. There were 3 separate instances.
[1 Mar 2023 12:23] MySQL Verification Team
Hi,

This issue is completely resolved.

This is a duplicate bug to the bug , mentioned above in the text. If you look at that bug, you will see that it is not fixed yet.
[1 Mar 2023 12:24] MySQL Verification Team
To be very precise, this bug is a duplicate of Bug #104365.
[11 Jul 2023 16:48] Russell Moore
Seems to still be a bug, however I did find the fix.  If you replace the quotation marks, the file opens without issue in Workbench.
[12 Jul 2023 12:48] MySQL Verification Team
HI Mr. Moore,

When a report is denoted as  a duplicate, it means that it is a bug, but that there is already an existing bug with the same cause.