[Mono-list] ByteFx.Data.MySQLClient.MySQLConnection - connection refused - mysql 4.0.13-2

Marco Canini marco.canini@fastwebnet.it
24 Jun 2003 22:43:11 +0200


On Tue, 2003-06-24 at 20:20, Maurizio Colucci wrote:
> On Tuesday 24 June 2003 00:54, Marco Canini wrote:
> > On Mon, 2003-06-23 at 23:57, Maurizio Colucci wrote:
> > > Hello,
> >
> > Hi
> >
> > > I am writing a small ASP.NET site for an exam. I am using with xsp
> > > from cvs.
> > >
> > > Everything so far seems to work fine... session management, asp:label,
> > > asp:textbox, asp:listbox.
> > >
> > > Now I just need to add some mysql query. :-)
> > >
> > > Is it possible with xsp, or must I install apache 2? :-(
> >
> > Well, there's no relation between mysql, xsp, apache 2: so no you can
> > stay with xsp.
> > What you need to use is ADO.NET (http://go-mono.org/ado-net.html).
> >
> > > Some quick starter/examples/pointers-to-existing-docs?
> >
> > Check the page on mysqlnet provider for a brief example on how to use
> > ado.net to access data,
> 
> Thanks Marco, that was helpful. Unfortunately the sample at
> 
>   http://www.go-mono.com/mysql.html
> 
> doesn't work, and the error message is too vague (connection refused).
it's not too vague: it just states that you can't connect to mysql :-)

your problem is that mysqld doesn't listen on the tcp/ip port but uses
only unix domain socket. this is the debian default policy for mysql,
you have to allow tcp/ip conncetion for mysql in order to use myslqnet
provide because since it uses only tcp/ip sockets.
go to /etc/mysql/my.cnf and comment out the line skip-networking, this
should solve your problem

> 
> using System;
>  using System.Data;
>  using ByteFX.Data.MySQLClient;
> 
>  public class Test
>  {
>     public static void Main(string[] args)
>     {
>        string connectionString =
>           "Server=localhost;" +
>           "Database=test;" +
>           "User ID=myuserid;" +
>           "Password=mypassword;";
>        IDbConnection dbcon;
>        dbcon = new MySQLConnection(connectionString);
>        dbcon.Open();
> 
> 
> the last line gives the following error:
> 
> Unhandled Exception: System.Net.Sockets.SocketException: Connection refused
> in (unmanaged) /usr/lib/libmono.so.0(mono_raise_exception+0x20) [0x400df3cb]
> in (unmanaged) /usr/lib/libmono.so.0 [0x400f924e]
> in <0x00059> 00 System.Net.Sockets.Socket:Connect (System.Net.EndPoint)
> in <0x000c2> 00 ByteFX.Data.MySQLClient.Driver:CreateSocketStream
>  (string,int) in <0x0002d> 00 ByteFX.Data.MySQLClient.Driver:Open
>  (string,int,string,string,bool) in <0x00138> 00
>  ByteFX.Data.MySQLClient.MySQLConnection:Open ()
> in <0x00083> 00 .Test:Main (string[])
> 
> 
> I am running mysql-server from debian sid. It is version
> 4.0.13-2. Might that be the reason? :-(( Please tell me it isn't...
> 
> 
> Trying to solve that, I looked into
> mcs/class/ByteFX.Data/mysqlclient/Connection.cs, and I saw that the
> connection string is different:
> 
> public MySQLConnection()
> {
> ConnectionString = "data source=localhost;user id=root;pwd=;database=mysql";
> }
> 
> So I replaced the connection string with that format, but I get the same
>  error.
> 
> What can I do?
> 
> Thanks again.
> 
> PS: of course I have started the mysql daemon and the connection string is
>  ok.
> 
> 
> 
> Maurizio
> 
> 
> 
> 
> 
> 
> 
> _______________________________________________
> Mono-list maillist  -  Mono-list@lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-list
-- 
Marco Canini <marco.canini@fastwebnet.it>
-- 
Marco Canini <marco.canini@fastwebnet.it>