| 1 | This guide will show you how to set up MySQL access for NovellMono on UnixLike systems. |
| 2 | |
| 3 | This guide assumes that: |
| 4 | * You are on a UnixLike box (Mac, Linux, etc.) |
| 5 | * You have installed the MySQL server |
| 6 | * You have started the MySQL server |
| 7 | * Have installed Cobra |
| 8 | * Have downloaded the MySQL connector for .NET to a directory called Packages |
| 9 | |
| 10 | From the command line: |
| 11 | {{{ |
| 12 | mkdir mysqlcon |
| 13 | cp Packages/mysql-connector-net-6.0.4-noinstall.zip mysqlcon/ |
| 14 | cd mysqlcon |
| 15 | unzip mysql-connector-net-6.0.4-noinstall.zip |
| 16 | cat README |
| 17 | mv mysql.data.dll MySql.Data.dll |
| 18 | gacutil -i MySql.Data.dll |
| 19 | # or: |
| 20 | sudo gacutil -i MySql.Data.dll |
| 21 | Installed MySql.Data.dll into the gac (/Library/Frameworks/Mono.framework/Versions/2.4/lib/mono/gac) |
| 22 | }}} |
| 23 | |
| 24 | If you like, you can "rm -rf" the "mysqlcon" directory as the .dll now resides in the GAC. You'll want to keep the original .zip around in case you need to install on another machine or reinstall. |
| 25 | |
| 26 | There are some other DLLs in there like mysql.data.cf.dll, mysql.data.entity.dll, mysql.visualstudio.dll and mysql.web.dll. I have not explored them other than to take a quick glance at the types contained therein. Everything I seem to need at this time is in the on DLL, MySql.Data.dll. |
| 27 | |
| 28 | The namespaces in MySql.Data.dll are: |
| 29 | |
| 30 | * MySql.Data.Common |
| 31 | * MySql.Data.!MySqlClient |
| 32 | * MySql.Data.!MySqlClient.Properties |
| 33 | * MySql.Data.Types |
| 34 | * zlib |
| 35 | |
| 36 | You can use .NET Reflector or some other tool to explore the DLL in more detail. |
| 37 | |
| 38 | Let's try it out. |
| 39 | {{{ |
| 40 | $ cd /usr/local/cobra/current/HowTo/ |
| 41 | $ cobra -ref:System.Data -ref:MySql.Data 600-AccessMySQL.cobra |
| 42 | (0): error: cannot find metadata file "MySql.Data.dll" (C#) |
| 43 | Compilation failed - 1 error, 0 warnings |
| 44 | Not running due to errors above. |
| 45 | }}} |
| 46 | |
| 47 | Well that's not very exciting. Let's try the full path: |
| 48 | {{{ |
| 49 | $ cobra -ref:System.Data \ |
| 50 | -ref:/Library/Frameworks/Mono.framework/Versions/2.4/lib/mono/gac/MySql.Data/6.0.4.0__c5687fc88969c44d/MySql.Data.dll \ |
| 51 | 600-AccessMySQL.cobra |
| 52 | userName=root, host=localhost |
| 53 | userName=root, host=mycomputer.local |
| 54 | userName=, host=mycomputer.local |
| 55 | userName=, host=localhost |
| 56 | }}} |
| 57 | |
| 58 | Look at the source code for 600-AccessMySQL.cobra to see how basic queries are done. |
| 59 | |
| 60 | At this point, I don't know why the absolute path is required given that the DLL was installed to the GAC. But you can bury this ugly detail in a build script. |
| 61 | |
| 62 | See also: ADO.NET, ActiveRecord |