KeyNotFoundException upon connecting to MariaDB
The article explains how to fix the problem where the message The given key was not present in the dictionary appears upon an attempt to connect to MariaDB 10.6.5 and later versions.
Starting from version 10.6.5, the MariaDB uses utf8mb3 encoding by default, but older MySQL Connector/NET versions do not support this encoding. Consequently, when SQL Examiner or SQL Data Examiner tries to connect to the MariaDB, the connection fails, and the error message appears. The error message can differ if a localized version of the .NET Framework is installed on your computer.
The simplest way to avoid the problem - installing the latest available MySQL Connector/NET. In our tests, the error occurred with version 8.0.21 but disappeared with 8.0.28.
However, if you cannot update the MySQL Connector/NET, you can avoid the error by configuring MariaDB and SQL Examiner Suite. The method below works in SQL Examiner Suite 126.96.36.199 and later versions.
Edit my.ini file and change encoding to utf8mb4
### [client] default-character-set=utf8mb4 [mysql] default-character-set=utf8mb4 # this is read by the standalone daemon and embedded servers [server] # this is only for the mysqld standalone daemon [mysqld] old_mode= character-set-server = utf8mb4 character-set-client=utf8mb4 collation-server = utf8mb4_unicode_520_ci init-connect='SET NAMES utf8mb4' ###
Then restart the service.
Add SQL Examiner internal variable to the Windows Registry
- Run regedit.exe
- Navigate to the HKEY_CURRENT_USER\SOFTWARE\SQL Accessories\Common\InternalVariables
- Create String Value named MySqlCharSet and assign the utf8 value
Run SQL Examiner and connect to the server.