[Tutorial] How to connect MySQL database in Xamarin.Android / iOS

Example Source Code

In order to connect to mysql, you need download the MySql connector from the below link :
You should use MySql.Data.cf.dll to connect MySQL, instead of using MySql.Data.dll .

The MySql.Data.CF.dll has some problem in compile phase.

It show the following error message.

Reference Required to assembly 'System, Version=, Culture=neutral, PublickeyToken=969bd8053d3322ac, Retargetable=Yes' containing the base class 'System.ComponentMode.Component'

However, You can path the dll file to make a workaround for this issue.

MySql.Data.CF (Path By SnowWolf725)

(Password: ShareBySnowWolf725)

In the runtime phase, you will get another error message.

Encoding name 'Windows-1252' not supported Parameter name: name

You need add “I18N.West ” into your reference, and add following code into your source code.

new I18N.West.CP1250 ();

new I18N.West.CP1250 ()

It is a workaround for Xamarin bug.

The default character set of mysql connector is cp1250.

So you need add “I18N.West ” into your reference.


However, In some version of Xamarin studio, It didn’t work.

Xamarin didn’t add I18N.West.dll into your IPA file.

So you need add new I18N.West.CP1250 () in your source code to hint Xamarin to add the dll into IPA file.

(If yours Xamarin studio will automatically add I18N.West.dll into your IPA file, you don’t need add this line).

For bypassing the dependency of system.data .

You can use Ildasm to disassembler the dll file.


It can convert the DLL file into IL file.

You can modify the IL source to let it depend on system.data .

After you modify the IL file, you can use ilasm to convert IL file into dll file.


  • ezekiel571

    Hey snowwolf Im using your mysql plugin for xamarin ios and Im having a few problems.
    Can you help me? My code compiles and works on the simulator, but after I deploy to an ipad, it cannot connect to the database.

    Please help! I can send you my code..