Using Mono to compile CSharp files on MacOS X

Download Connector/Net ( and extract the contents to a directory. Ensure the file MySql.Data.dll is present.

You must register the Connector/Net component, MySql.Data, in the Global Assembly Cache (GAC). In the current directory enter the gacutil command:

sudo gacutil /i MySql.Data.dll

You are now ready to compile your application.

vi hello.cs
mcs hello.cs

You must ensure that when you compile your application you include the Connector/Net component using the -r: command-line option.

mcs -r:System.dll -r:System.Data.dll -r:MySql.Data.dll HelloWorld.cs

The referenced assemblies depend on the requirements of the application, but applications using MySQL Connector/Net must provide -r:MySql.Data at a minimum.

Check your installation by running the compiled program.

mono hello.exe
Hello, World