15

I am trying to run a server with a MySQL Database, however I keep getting this huge error and I am not sure why.

[21:15:49,107] Server Properties Lookup: Error While Initialization
DOL.Database.DatabaseException: Table DOL.Database.ServerProperty is not registered for Database Connection...
   at DOL.Database.ObjectDatabase.SelectAllObjects[TObject]()
   at DOL.GS.ServerProperties.Properties.get_AllDomainProperties()
   at DOL.GS.ServerProperties.Properties.InitProperties()
   at DOL.GS.GameServer.InitComponent(Action componentInitMethod, String text)```

also this error

[21:15:35,991] ExecuteSelectImpl: UnHandled Exception for Select Query "DESCRIBE `Specialization`"
System.NotSupportedException: Character set 'utf8mb3' is not supported by .Net Framework.
   at MySql.Data.MySqlClient.CharSetMap.GetCharacterSet(DBVersion version, String charSetName)
   at MySql.Data.MySqlClient.MySqlField.SetFieldEncoding()
   at MySql.Data.MySqlClient.NativeDriver.GetColumnData(MySqlField field)
   at MySql.Data.MySqlClient.NativeDriver.GetColumnsData(MySqlField[] columns)
   at MySql.Data.MySqlClient.Driver.GetColumns(Int32 count)
   at MySql.Data.MySqlClient.ResultSet.LoadColumns(Int32 numCols)
   at MySql.Data.MySqlClient.ResultSet..ctor(Driver d, Int32 statementId, Int32 numCols)
   at MySql.Data.MySqlClient.Driver.NextResult(Int32 statementId, Boolean force)
   at MySql.Data.MySqlClient.MySqlDataReader.NextResult()
   at MySql.Data.MySqlClient.MySqlDataReader.Close()
   at MySql.Data.MySqlClient.MySqlCommand.ResetReader()
   at MySql.Data.MySqlClient.MySqlCommand.ExecuteReader(CommandBehavior behavior)
   at MySql.Data.MySqlClient.MySqlCommand.ExecuteDbDataReader(CommandBehavior behavior)
   at System.Data.Common.DbCommand.ExecuteReader()
   at DOL.Database.SQLObjectDatabase.ExecuteSelectImpl(String SQLCommand, IEnumerable`1 parameters, Action`1 Reader)```

1
  • 1
    "I am trying to run a server with a MySQL Database" Did you mean that you were trying to connect to MySQL server from C# application? If that is the case, try using MySqlConnector package instead of MySql.Data. MySqlConnector supports utf8mb3. That worked for me in similar case.
    – Dawid Ohia
    Jun 10, 2022 at 6:57

7 Answers 7

37

There is an update available to the MySQL Connector/NET.

After updating to version 8.0.28 (NuGet package MySql.Data) everything is working again.

4
  • 2
    This is the short and quick answer! Worked for me as well. Thanks
    – sanpat
    Jan 27, 2022 at 20:51
  • 3
    exactly! I installed MySQL Server - the latest version, but did not update the Nuget package of client software, which was 8.0.19. After updating it an error has gone. Thanks!
    – Ivan P.
    May 3, 2022 at 10:57
  • The same worked for me. I updated nuget package version to be the same as mysql docker image version . Thanks.
    – r23
    Aug 30, 2022 at 14:16
  • Thank you, taking me left and right and no where. That's a real answer Sep 13 at 14:30
3

In my case I had installed 10.6.4-MariaDB that came by default with utf8mb3.

I got the same error when trying to read tables.

I had fixed it by changing all charset settings in MariaDB configuration to utf8mb4.

Then dumping my database and importing it again. This time specifying utf8mb4 when creating the database.

So the normal SELECT,UPDATE queries were working fine, no more error.

But I kept getting an error when my application was calling stored procedures.

I think maybe that was because the stored procedures are saved into the information_schema database, that was still utf8mb3 and I could not find a way to change it to utf8mb4.

After losing a lot of time trying to implement some weird workarounds, I had run into this bug report:

MariaDB 10.6 cannot be used from C# client applications:
https://jira.mariadb.org/browse/MDEV-26105?attachmentViewMode=list

One of the users there says:

The system character set is used only internally by MariaDB and does not need to be changed. In my client program written in C# here is what I did after connecting to make it work with MariaDB 10.6:

MySqlCommand setcmd = new MySqlCommand("SET character_set_results=utf8", conn);
int n = setcmd.ExecuteNonQuery();
setcmd.Dispose();

in this command utf8 was defaulted to utf8mb4 by MariaDB due to the old_mode setting. That is the results charset that was causing problem with my program.

So I ended up adding this in my VB project just before executing my stored procedures:

Dim sqlCommand As New MySqlCommand
sqlCommand.Connection = _MySqlCn
sqlCommand.CommandText = "SET character_set_results=utf8"
sqlCommand.ExecuteNonQuery()

This fixed the error for me.

Also, this is what I had previously changed in MariaDB server configuration:

[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'
1
  • In my case changing package from MySql.Data to MySqlConnector worked (staying with utf8mb3 in database settings). MySqlConnector package supports utf8mb3.
    – Dawid Ohia
    Jun 10, 2022 at 6:30
1

Maybe a solution. Source : https://dba.stackexchange.com/questions/8239/how-to-easily-convert-utf8-tables-to-utf8mb4-in-mysql-5-5

Change your CHARACTER SET AND COLLATE to utf8mb4.

For each database:

ALTER DATABASE
    database_name
    CHARACTER SET = utf8mb4
    COLLATE = utf8mb4_unicode_ci;

For each table:

ALTER TABLE
    table_name
    CONVERT TO CHARACTER SET utf8mb4
    COLLATE utf8mb4_unicode_ci;

For each column:

ALTER TABLE
    table_name
    CHANGE column_name column_name
    VARCHAR(191)
    CHARACTER SET utf8mb4
    COLLATE utf8mb4_unicode_ci;

Worked for me with Powershell and MariaDB 10.6. Hope this will help ;)

1

In my case (MariaDB 10.6) helped changing character-set-server in ...\MariaDB 10.6\data\my.ini from utf8 to utf8mb4. Now everything works fine.

1

For .NET CORE 5.0, I had to upgrade 3 NuGet Packages from v.5.0.0 to v.5.0.13:

  1. MySql.EntityFrameworkCore
  2. Microsoft.EntityFrameworkCore.Design
  3. Microsoft.EntityFrameworkCore.Tools
1

I "solved" this by abandoning Oracle's MySQL Connector/Net and rewrote the application to use MySqlConnector. It was very little work, but I also had to rewrite everything about the user management since I had it depend on MySql.Web, and this was not as easy.

0

I solved the problem by changing the MySQL Connector/NET version to 8.0.28

Download do MySQL Connector/NET

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.