I am starting a thread to document a problem I found getting Mono to connect to MySQL above 4.0 databases, that affects the ability to install MojoPortal.
I installed on Debian Linux running XSP off Mono 1.0.0 with Mysql 4.0
When I originally installed MojoPortal, I got the following error:
ByteFX.Data.MySqlClient.MySqlException: Unable to connect to any of the specified MySQL hosts
in <0x00158> ByteFX.Data.MySqlClient.Driver:Open (ByteFX.Data.MySqlClient.MySqlConnectionString)
in <0x0003c> ByteFX.Data.MySqlClient.MySqlInternalConnection:Open ()
in <0x000ef> ByteFX.Data.MySqlClient.MySqlPool:CreateNewPooledConnection ()
in <0x00214> ByteFX.Data.MySqlClient.MySqlPool:GetPooledConnection ()
in <0x00052> ByteFX.Data.MySqlClient.MySqlPool:GetConnection ()
in <0x00112> ByteFX.Data.MySqlClient.MySqlPoolManager:GetConnection (ByteFX.Data.MySqlClient.MySqlConnectionString)
in <0x0007c> ByteFX.Data.MySqlClient.MySqlConnection:Open ()
I confirmed that the database was indeed located on localhost, and I was able to reproduce the problem on the remote server with the following small C# Program:
using System;
using ByteFX.Data.MySqlClient;
//using MySql.Data.MySqlClient;
namespace hello
{
??? class MainClass
??? {
??? ??? public static void Main(string[] args)
??? ??? {
??? ??? ??? Console.WriteLine("Hello World!");
??? ??? ??? MySqlConnection conn = new
MySqlConnection("Server=localhost;Database=luke_my;User ID=luke_my;Password=foo;");
??? ??? ??? MySqlCommand cmd = new MySqlCommand("SELECT * FROM foo;",conn);
??? ??? ??? cmd.Connection.Open( );
??? ??? ??? cmd.ExecuteNonQuery( );
??? ??? ??? cmd.Connection.Close( );
??? ??? ??? Console.WriteLine("Done");
??? ??? }
??? }
}
When compiled, this produced the exact same error.
On trying the same thing on my local computer running windows with MySql 4.17, It gave me an error with authentication, saying that ByteFX is an outdated client and can't support MySQL's new encrypted log ins. I did a little homework, and found that ByteFX has been replaced with this:
http://dev.mysql.com/downloads/connector/net/1.0.html
For the newer MySQL releases.
Which is the current connector, made by the makers of ByteFX.
It seems to have all the same functions as the old ByteFX ones, so very little needs to be changed.I tried it out on WinXP under .NET SDK 1.1, and it worked! I then tried it on Mono 1.0.1 on my winXP box, and Mono 1.0 on the Linux server, and got a new error on each one,(same for each)? which says something to the effect of MySQL returned Unknown encoding, 'latin1' .
This it turns out is due to a bug in Mono in versions less than 1.0.4 (I think) I upgraded to Mono 1.0.5 from 1.0.1.
It worked!
I have not told my sysadmin to upgrade yet, so the final test? is not yet complete. But based on current evidence, this looks like the cause of the original problem: ByteFX can't work with the encrypted password system, and the newer connector is needed. And in order to use the newer connection on Mono without bugs, a version of Mono above 1.0.4 (I think, I can confirm that 1.0.5 works )is needed.
Anyway, I just wanted to run all this by the author, wonder what you think.