MySQL in unity project

Hi everyone, i am trying to import Mysql.data.dll (of net8.0) into my Unity project because i need to access a database from unity c# scripts.

When importing the dll file i am getting this error:

error CS1705: Assembly ‘MySql.Data’ with identity ‘MySql.Data, Version=8.3.0.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d’ uses ‘System.Runtime, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a’ which has a higher version than referenced assembly ‘System.Runtime’ with identity ‘System.Runtime, Version=4.1.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a’

Can anyone help solve this problem?

Thank you in advance

You clearly used the wrong version for your Unity / Mono / .NET version. Look up which is the equivalent Mono version and grab one lower than that. I usually used .NET 3.5 libraries as they usually work fine.

Apart from that, hopefull you’re not developing a game or any client application unless you try to access the mysql server on the client machine. You NEVER connect or even expose a MySQL / MariaDB server to the internet, let alone include your credentials in a game that is shipped to anyone. You generally communicate with SQL servers through a well defined API which requires server side code / logic. Usually through a web-server. So the actual database connection happens on the server side, hidden from any client. The reasons are:

  • The MySQL / MariaDB protocol does not have any way to fight off DDoS attacks.
  • Whatever permissions the user credentials has could be used / abused by any hacker / script kiddy
  • So the only way would be to set strict rules and only allow the execution of certain stored procedures / functions. Otherwise clients could read your whole database and depending on the write permissions could even wipe your whole database.