MYSQL & Unity, Where to get the libraries to reference?

Hey guys. Theres a lot on MSQL and unity out there in the forums.

But they all have broken links to demo projects and libraries needed. I cant even begin trying the tutorials people offer because I cant reference the libraries in mono develop.

There are asset store items for MySql but even there the links to documentation or demo’s etc are broken. No documentation , contact, or website. So I’m hesitant to spend any money when they cant even keep their website references on the asset store up to date.

Ive never tried using Mysql in unity & there seems to be no way to begin.

I see a lot of people using DLL’s or unity imports in their tutorials that I cant find anywhere.

Also this is an Android project. Are the DLL’s I need even going to work once I deploy the project on to an android device?

Any advice on where to begin?

Hello there, I have faced the same problem yesterday and I’ve found a satisfying solution that works both on PC and Android.

  • Step 1:
    Download .DLL file from here matching your Visual studio project target .NET version (for me 3.5, version worked just fine). If you download a wrong version you will get an error in Unity editor.
    links to download the file: MySql.Data.DLL : Free .DLL download. -
    or this one:

  • Step 2:
    Unpack the .DLL file and include it in the project (put it anywhere inside of the Assets folder).

  • Step 3: Program your connection to the database :wink:
    here is a short example:

     using System;
     using System.Data;
     using MySql.Data;
     using MySql.Data.MySqlClient;
     public class Tutorial4
         public static void Main()
             string connStr = "server=localhost;user=root;database=world;port=3306;password=******";
             MySqlConnection conn = new MySqlConnection(connStr);
                 Console.WriteLine("Connecting to MySQL...");
                 string sql = "SELECT COUNT(*) FROM Country";
                 MySqlCommand cmd = new MySqlCommand(sql, conn);
                 object result = cmd.ExecuteScalar();
                 if (result != null)
                     int r = Convert.ToInt32(result);
                     Console.WriteLine("Number of countries in the world database is: " + r);
             catch (Exception ex)

Im using unity 2019 and i can get the connection to open. And using the ExecuteScalar() with a COUNT() seems to work just fine. However when i try to do “SELECT username FROM users” and using other OLD tutorials I used the code below I get a System.TimeoutExeption: error

// TEST 2
Debug.Log("Test 2");
string sql2 = "SELECT username FROM users";
cmd = new MySqlCommand(sql2, con);
rdr = cmd.ExecuteReader();
while (rdr.Read())

So i tried something else.
“SELECT * FROM users”
And this time i get a different error.

The given key was not present in the
at System.Collections.Generic.Dictionary`2[TKey,TValue].get_Item
(TKey key) [0x0001e] in
at MySql.Data.MySqlClient.CharSetMap.GetCharacterSet
(MySql.Data.Common.DBVersion version,
System.String CharSetName) [0x00000]
at MySql.Data.MySqlClient.MySqlField.SetFieldEncoding
() [0x0004b] in
at MySql.Data.MySqlClient.MySqlField.set_CharacterSetIndex
(System.Int32 value) [0x00007] in
at MySql.Data.MySqlClient.NativeDriver.GetColumnData
field) [0x000ad] in
at MySql.Data.MySqlClient.NativeDriver.GetColumnsData
columns) [0x00004] in
at MySql.Data.MySqlClient.Driver.GetColumns
(System.Int32 count) [0x0001c] in
at MySql.Data.MySqlClient.ResultSet.LoadColumns
(System.Int32 numCols) [0x00000] in
at MySql.Data.MySqlClient.ResultSet…ctor
(MySql.Data.MySqlClient.Driver d,
System.Int32 statementId, System.Int32
numCols) [0x00029] in
at MySql.Data.MySqlClient.Driver.NextResult
(System.Int32 statementId) [0x00035]
at MySql.Data.MySqlClient.MySqlDataReader.NextResult
() [0x00053] in
at MySql.Data.MySqlClient.MySqlDataReader.Close
() [0x00020] in
at MySql.Data.MySqlClient.MySqlCommand.ResetReader
() [0x00020] in
at MySql.Data.MySqlClient.MySqlCommand.ExecuteReader
(System.Data.CommandBehavior behavior)
[0x002d1] in
at MySql.Data.MySqlClient.MySqlCommand.ExecuteReader
() [0x00000] in
at (wrapper remoting-invoke-with-check)
at DatabaseHandler.Awake () [0x00176] in C:\Users\St Francis
01\Desktop\AGD\MySQL\Link To

DatabaseHandler:Awake() (at Assets/Scripts/DatabaseHandler.cs:77)