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.

Cause

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.

Resolution

Method 1

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.

Method 2

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 8.0.0.109 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

  1. Run regedit.exe
  2. Navigate to the HKEY_CURRENT_USER\SOFTWARE\SQL Accessories\Common\InternalVariables
  3. Create String Value named MySqlCharSet and assign the utf8 value

Run SQL Examiner and connect to the server.

  • Product:  SQL Examiner, SQL Data Examiner
  • Edition:  All
  • Version:  2008 and later
  • Published:  2022-01-28
  • Last Updated:  2022-01-30

Do not see what you are looking for?
Please submit a support request