Problem Connecting to MySQL from AS

Posted on 2004-11-07
Last Modified: 2012-06-22
Hi friends,

I have Windows XP running IIS in, and I'm using ASP.NET to connect to a MySQL DB in a Linux computer at  My code is

OdbcConnection cn = new OdbcConnection("Driver={MySQL ODBC 3.51 Driver}; Server=; Port=3306; Option=3; Database=Jazon; Uid=root; Password=;");

I get the following error:

ERROR [HYT00] [MySQL][ODBC 3.51 Driver]Host '' is not allowed to connect to this MySQL server

I have the MyODBC 3.5 driver installed in the Windows computer, and I know MySQL is running properly because I'm able to connect and query it from a PHP page in the Linux computer.

Any help would be so greatly appreciated,

Jazon from Jacksonville, FL
Question by:piratepatrol

    Expert Comment

    i think you are running php code on sam machine which runs mysql server.. so u use local user to communicate with mysql you need to create a remote user ..
    you need to create a user, use mysql front ( and create user and dont select localhost but write there (in the domain part) '%' which means user can use server from outside of that computer or change rules for root user.. make it % not localhost

    user data is saved under a table in mysql =>  database > mysql > users or something like that you can edit it manually too but i can tell you that using mysql front is much more simpler..

    ps: if you use fedora or rh 8-9 check /etc/hosts file ..
    LVL 3

    Author Comment

    There's a root user in the user table.  Its Host was localhost.  I updated that to % with an update query.  I still get the same problem.  (I use this root to log in from the .aspx page).  Where am I going wrong?  This bites.

    Accepted Solution

    can u try to create another user and change the code from aspx ?
    so try it in that way too..
    and btw can you connect to mysql server from your computer (which runs aspx) with mysql front or some other clients ?  please a new user give all permissions  host = % and retry with aspx and then with mysqlfront ..
    LVL 3

    Author Comment

    Hi Lc001tr,

    I made the following insert into mysql > user ...

    insert info user values ('%', 'jazon', 'pwd', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', );

    In my PHP, I have

    $cn = @mysql_connect("%", "jazon", "pwd");

    With these, I am unable to connect to MySQL from PHP.  Any thoughts?  

    Thank you so much.
    LVL 3

    Author Comment

    Hi Lc001tr,

    I added the following line to /etc/hosts, and now it works:            %

    My connection string is

    $cn = @mysql_connect("%", "root", "");

    I can now connect to MySQL from PHP again.  However, I now have a new problem with my connection from my aspx page:

    ERROR [HYT00] [MySQL][ODBC 3.51 Driver]Access denied for user: 'root@' (Using password: NO) is my Windows computer, and is my Linux computer (with MySQL).  Any thoughts on this?


    Expert Comment

    you can write etc/hosts file % .. i think thats it

    Featured Post

    Javascript: Crash Course

    Javascript is not only emerging as the most important language to know, it's flexibility is unique. With Javascript being deployed on the web, mobile and even the desktop this is the one language that all technologists need to know.

    Join & Write a Comment

    Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
    Uploading files to the web server has become common part of almost any kind of web application. People use different technologies to solve this, but regardless of the technology used, it is always useful to have some kind of progress indicator shown…
    This video teaches users how to migrate an existing Wordpress website to a new domain.
    This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

    729 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    21 Experts available now in Live!

    Get 1:1 Help Now