Mono, Linux and MySQL. Getting everything working nicely.

So, you’re a Linux guy who wants to make cool stuff with the Mono version of the .Net framework and MySQL?  Cool story bro. Sadly, there’s no ‘out of the box’ support for MySQL with Mono. That said, it’s reasonably easy to get it working. This blog post will run you through installing the MySQL DLLs so you can start hacking away.


  • A brain.
  • Hands.
  • 20 minutes
  • A MySQL Server.

Got those? Awesome.

So, first off open up a terminal and download MonoDevelop. This will also download any and all dependencies, including Mono itself. In Ubuntu, it’s sudo apt-get install monodevelop. Depending on what distro you are using, you may be using a different package manager and you’ll use a somewhat different command.

Now go here and download the latest version of the MySQL .Net connector. Make sure you select the Mono version and not the Microsoft Windows one. Once you’ve got that, you’ll probably want to unzip it. Navigate to the directory where you downloaded the zip file and run unzip <name of file>. You’ll now have two folders called “V2” and “V4”. These contain all the libraries you’re going to have to put into your GAC (Global Assembly Cache).

Now, unfortunately you’re going to have to rename each library. Seriously. Whoever uploaded them didn’t exactly realize that this sort of thing is case sensitive. So, go ahead and rename them to the correct naming convention.

mv MySql.Data.Cf.dll

As you can see, you’re changing “mysql” to “MySQL” with every other part of the filename that isn’t “.dll” having the first character uppercase. Makes sense? Good.

Right, now copy everything from “V2” into /usr/lib/mono/2.0 and everything from “V4” into /usr/lib/mono/4.0. Done? Cool. You’re almost finished. Now you get to put it into your Global Assembly Cache. This is handled by a rather nice utility called gacutil which should have been installed when you downloaded MonoDevelop.

Syntax is fairly simple here. It’s just gacutil -i <filename>. Do that for each DLL, and you’re sorted. Seriously, there’s nothing more to do now. Promise. Now, reward yourself by making something cool with MySQL and C#.

About Matthew Hughes

Matthew Hughes is a software developer, student and freelance writer from Liverpool, England. He is seldom found without a cup of strong black coffee in his hand and absolutely adores his Macbook Pro and his camera. You should follow him at @matthewhughes.


  1. 3xThanks….

    my notes

    my contribute notes


    # Rename Files to Linux
    $ mv v2.0/ v2.0/MySql.Data.CF.dll
    $ mv v2.0/ v2.0/MySql.Data.dll
    $ mv v2.0/ v2.0/MySql.Data.Entity.dll
    $ mv v2.0/mysql.web.dll v2.0/MySql.Web.dll
    $ mv v4.0/ v4.0/MySql.Data.dll
    $ mv v4.0/ v4.0/MySql.Data.Entity.dll
    $ mv v4.0/ v4.0/MySql.Data.Entity.EF6.dll
    $ mv v4.0/mysql.web.dll v4.0/MySql.Web.dll
    $ mv v4.5/ v4.5/MySql.Data.dll
    $ mv v4.5/ v4.5/MySql.Data.Entity.EF5.dll
    $ mv v4.5/ v4.5/MySql.Data.Entity.EF6.dll
    $ mv v4.5/mysql.web.dll v4.5/MySql.Web.dll

    #Copy To Mono RunTime
    $ sudo cp v2.0/*.* /usr/lib/mono/2.0
    $ sudo cp v4.0/*.* /usr/lib/mono/4.0
    $ sudo cp v4.5/*.* /usr/lib/mono/4.5

    #Install in GAC
    $ sudo gacutil -i /usr/lib/mono/2.0/MySql.Data.CF.dll
    $ sudo gacutil -i /usr/lib/mono/2.0/MySql.Data.dll
    $ sudo gacutil -i /usr/lib/mono/2.0/MySql.Data.Entity.dll
    $ sudo gacutil -i /usr/lib/mono/2.0/MySql.Web.dll
    $ sudo gacutil -i /usr/lib/mono/4.0/MySql.Data.dll
    $ sudo gacutil -i /usr/lib/mono/4.0/MySql.Data.Entity.dll
    $ sudo gacutil -i /usr/lib/mono/4.0/MySql.Data.Entity.EF6.dll
    $ sudo gacutil -i /usr/lib/mono/4.0/MySql.Web.dll
    $ sudo gacutil -i /usr/lib/mono/4.5/MySql.Data.dll
    $ sudo gacutil -i /usr/lib/mono/4.5/MySql.Data.Entity.EF5.dll
    $ sudo gacutil -i /usr/lib/mono/4.5/MySql.Data.Entity.EF6.dll
    $ sudo gacutil -i /usr/lib/mono/4.5/MySql.Web.dll

    #Check Installed Assemblies
    $ sudo gacutil -l | grep MySql

    MySql.Data, Version=, Culture=neutral, PublicKeyToken=c5687fc88969c44d
    MySql.Data.CF, Version=, Culture=neutral, PublicKeyToken=c5687fc88969c44d
    MySql.Data.Entity, Version=, Culture=neutral, PublicKeyToken=c5687fc88969c44d
    MySql.Data.Entity.EF5, Version=, Culture=neutral, PublicKeyToken=c5687fc88969c44d
    MySql.Data.Entity.EF6, Version=, Culture=neutral, PublicKeyToken=c5687fc88969c44d
    MySql.Web, Version=, Culture=neutral, PublicKeyToken=c5687fc88969c44d

    # Pack files
    $ tar cvzf mysql-connector-net-6.8.3-ubuntu-12.04.mono.tar.gz /usr/lib/mono/2.0/MySql* /usr/lib/mono/4.0/MySql* /usr/lib/mono/4.5/MySql*

    Done !

    Once Again Thanks for share 🙂

Leave a Reply