[Mono-devel-list] MySQL problem

Simon Bain sibain at tendotzero.com
Sun Feb 27 11:47:07 EST 2005


Hi.

The error is a MySQL error which says that user paul is not allowed to
connect from localhost.localdomain.

Give paul access rights by adding them to the mysql.user table and then
all will be cool as far as that error is concerned.

Below is an SQL statement which will do this. Change the username and
password and also the access rights required.

use mysql;
#INSERT USER
INSERT INTO user (Host, User, Password, Select_priv, Insert_priv,
Update_priv, Delete_priv, Create_priv, Drop_priv, Reload_priv,
Shutdown_priv, Process_priv, File_priv, Grant_priv, References_priv,
Index_priv, Alter_priv) VALUES
('localhost.localdomain','paul',PASSWORD('password'),'Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y');

OK if you are on a win system save this to C:\mysql\bin as adduser.sql

go to a command prompt and logon to MySQL with root and type

source adduser.sql   <enter>

If you are on linux save this onto the system. logonto MySQL as root and
type source /path/to/adduser.sql  <enter>

This should sort out the problem.

All the best
Simon

<quote who="Paul">
> Hi,
>
> I've used the MySQL snippet on the mono-project website to access an SQL
> database that I have set up.
>
> The code looks like this (so you don't need to find it!)
>
> using System;
> using System.Data;
> using ByteFX.Data.MySqlClient;
>
> public class Test
> {
>   public static void Main(string[] args)
>   {
>     string connectionString = "Server=localhost;" + "Database=employee;"
> +
>       "User ID=paul;" + "Password=password";
>     IDbConnection dbcon;
>     dbcon = new MySqlConnection(connectionString);
>     dbcon.Open();
>     IDbCommand dbcmd = dbcon.CreateCommand();
>     string sql = "SELECT firstname, lastname " + "FROM employee";
>     dbcmd.CommandText = sql;
>     IDataReader reader = dbcmd.ExecuteReader();
>     while(reader.Read())
>     {
>       string FirstName = (string) reader["firstname"];
>       string LastName = (string) reader["lastname"];
>       Console.WriteLine("Name: " + FirstName + " " + LastName);
>     }
>
>     reader.Close();
>     reader = null;
>     dbcmd.Dispose();
>     dbcmd = null;
>     dbcon.Close();
>     dbcon = null;
>   }
> }
>
> This compiles fine, but when I run it, I get the following
>
> Unhandled Exception: ByteFX.Data.MySqlClient.MySqlException: #HY000Host
> 'localhost.localdomain' is not allowed to connect to this MySQL server
> in <0x000b0> ByteFX.Data.MySqlClient.Driver:ReadPacket ()
> in <0x00134> ByteFX.Data.MySqlClient.Driver:Open
> (ByteFX.Data.MySqlClient.MySqlConnectionString settings)
> in <0x00039> ByteFX.Data.MySqlClient.MySqlInternalConnection:Open ()
> in <0x000b1> ByteFX.Data.MySqlClient.MySqlPool:CreateNewPooledConnection
> ()
> in <0x0018a> ByteFX.Data.MySqlClient.MySqlPool:GetPooledConnection ()
> in <0x00042> ByteFX.Data.MySqlClient.MySqlPool:GetConnection ()
> in <0x000cf> ByteFX.Data.MySqlClient.MySqlPoolManager:GetConnection
> (ByteFX.Data.MySqlClient.MySqlConnectionString settings)
> in <0x0004b> ByteFX.Data.MySqlClient.MySqlConnection:Open ()
>
> Now, I have a similar program in C which works fine. Is there some
> difference between accessing something in C# than in C? I've seen this
> error before, but only when messing about with mysqladmin
>
> TTFN
>
> Paul
>
> --
> "I like blinking me" - Helen, Big Brother 2 contestant
>


-- 
Simon Bain
TENdotZERO
0845 056 3377
44 1234 359090
44 (0) 7793 769 846



More information about the Mono-devel-list mailing list