[Mono-list] Simple MySql Connection Problem

Jan van der watt janvanderwatt at gmail.com
Mon Aug 24 04:09:58 EDT 2009


Hi Chris,
Lots of things can go wrong, but usually it's one of these:

- "username at localhost" was not granted access to the DB;
[grant select, update, insert, delete on myDatabas.* to
'username'@'localhost' identified
by 'myPassword';]
(did you mean myDatabasE? - you can also "grant ALL ...")
[http://dev.mysql.com/doc/refman/5.1/en/grant.html]

- mysql is not accepting TCP connections (could be firewall (even for local
connections), or MySql settings)
[
http://www.cyberciti.biz/tips/how-do-i-enable-remote-access-to-mysql-database-server.html
]

- mysql is not running
[check that the service is started when the machine boots]

If this doesn't point you in the right direction, perhaps you can post the
exact error message.

Best regards

Jan



On Wed, Jul 15, 2009 at 12:14 PM, Chris Tulabut <soul_aspect at yahoo.com>wrote:

>
> hi,
> im developing a c# console app that will connect to a mysql database
> locally
> and plan on using it on a linux machine.
>
> here's my test code:
>
> using System;
> using System.Collections.Generic;
> using System.Text;
> using MySql.Data.MySqlClient;
>
> namespace TestDBConnect
> {
>    class Program
>    {
>
>        static void Main(string[] args)
>        {
>             string ConnectionString = "Server=localhost;" +
> "Database=myDatabas;" + "User ID=username;" + "Password=myPassword;" +
> "Pooling=false;";
>             try
>             {
>                MySqlConnection conn = new
> MySqlConnection(ConnectionString);
>                conn.Open();
>
>                Console.WriteLine(conn.ServerVersion);
>            }
>            catch (MySql.Data.MySqlClient.MySqlException ex)
>            {
>
>                switch (ex.Number)
>                {
>                    case 0:
>                        Console.WriteLine(DateTime.Now + " >> " + "Cannot
> connect to database server.");
>                        break;
>                    case 1045:
>                        Console.WriteLine(DateTime.Now + " >> " + "Invalid
> username/password, please try again");
>                        break;
>                    default:
>                        Console.WriteLine(ex.Message);
>                        break;
>                }
>            }
>
>
>        }
>    }
> }
>
>
> i compile the code:
> gmcs program.cs -r:mysql.data.dll
>
> i try a test run
> program.exe <----- works fine
>
> mono program.exe <-----------unable to connect to the specified mysql hosts
>
> ive tried Mysql.data.dll connector version 6.1 and 5.2 both with the same
> error
> mysql.data.dll version 1.0.7 enters Case 0 on my Switch statement and then
> throws "unable to connect to the specified mysql hosts"
> im using MS VS 2005
> windows vista
>
> please help, im really stumped.
>
> --
> View this message in context:
> http://www.nabble.com/Simple-MySql-Connection-Problem-tp24490824p24490824.html
> Sent from the Mono - General mailing list archive at Nabble.com.
>
> _______________________________________________
> Mono-list maillist  -  Mono-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-list
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-list/attachments/20090824/26656fc9/attachment-0001.html 


More information about the Mono-list mailing list