How to install the mysql connector for C#?

7,525

After download the .zip file I unzipped this.

This have a couple of folders named "V2" and "V4"

Both folders have the mysql.data.dll (the file that we need to register) but I used the higher version number (V4):

  1. Instal mono-gac entering this in terminal:

    sudo apt-get install mono-gac
    
  2. Now register the library:

    sudo gacutil -i ~/UNZIPPED_FOLDER/V4/mysql.data.dll #Replace it with your path
    

And done!

Now when you will compile a file you need to add -r:mysql.data.dll to the command line option. Example:

gmcs Main.cs -r:mysql.data.dll #if the dll file is in the same path

All this steps were reached thanks to @drch.

Share:
7,525

Related videos on Youtube

Lucio
Author by

Lucio

Web Developer building cool stuff on Spotify! Do you like recursion? Enjoy it! Full Profile

Updated on September 18, 2022

Comments

  • Lucio
    Lucio over 1 year

    I installed Wine and now I have setup Mono & .NET

    When I try to compile the next sentence, I get an error because I don't have the MySQL connector installed on my system.

    using MySql.Data.MySqlClient;
    

    The type or namespace name `MySql' could not be found. Are you missing a using directive or an assembly reference?

    I don't understand very well why, because I can connect to MySQL using the MonoDeveloped IDE and I can submit queries obtaining responses with excellent results!

    Searching on Internet, I found out that I need the MySQL connector (for the .NET + Mono platform) to compile this code.

    So I downloaded the connector and read Installing Connector/NET on Unix with Mono from MySQL Reference, but I have no idea where is the Mono project installation folder.

    How can I install this connector so the code can be compiled without errors?