Page 1 of 1

Access denied for user 'ODBC'@'localhost'

PostPosted: 10. March 2010 22:10
by azsl1326
Hello All,

I just installed XAMPP on my home machine for windows 7. I am trying to access the mysql database using Flex and AMFPHP. I am getting the following error when I attempting to connect via Flex / PHP - Access denied for user 'ODBC'@'localhost' (using password: NO); See PHP code below:

Code: Select all
Access denied for user 'ODBC'@'localhost' (using password: NO)
<?php

   class LightBoxes{

      public function __constructor(){
   
         $connect = mysql_connect("localhost","root","mypassword");
         mysql_select_db("digitalassets",$connect);
         
      }
      
      function read(){
      
         $query = "SELECT * FROM lightboxes_tbl";
         $result = mysql_query($query) or die(mysql_error());
         
         return mysql_error();
         
      }
      
   }
}

?>


'


I have researched this via Google and can not seem to find a solution that will work on my machine - I am also experiencing the same issue on my work machine as well. I set up the user 'root' with a passwor via the XAMPP security page. I currently don't have the user 'ODBC'.

Any information to help resolve this issue is certainly appreciated.

Re: Access denied for user 'ODBC'@'localhost'

PostPosted: 11. March 2010 05:58
by Altrea
ODBC is a default user for the db connection, if no login data is given.

I think the problen is not the class, but the place where you call/use the db connect

Re: Access denied for user 'ODBC'@'localhost'

PostPosted: 11. March 2010 06:04
by azsl1326
Thanks for the assistance. Actually I just ended up resolving the issue by doing the following:

Code: Select all
mysql>GRANT ALL ON <your database name>.* TO 'ODBC'@'localhost';


I have never had to do this in the past as I was always able to connect using root and the password.

Re: Access denied for user 'ODBC'@'localhost'

PostPosted: 11. March 2010 06:07
by Altrea
That will not solve all your code problems, but ends up in that every database connect will have all access to your database, which is highly insecure!

Re: Access denied for user 'ODBC'@'localhost'

PostPosted: 11. March 2010 15:43
by azsl1326
This is the only solution I could find that would work. I am not too worried about security as it is only for internal use. However, with that said, I would like to find/know the best way to resolve this issue.

Re: Access denied for user 'ODBC'@'localhost'

PostPosted: 11. March 2010 16:26
by Altrea
ah, i get it.

You tried to use a constructor to establish the database connection, but named the method not correctly.

__constructor(...) should be __construct(...), otherwise your constructor will never be called.
Because your class never called the constructor, it tries to use a default connection.

Re: Access denied for user 'ODBC'@'localhost'

PostPosted: 11. March 2010 16:45
by azsl1326
Altrea wrote:ah, i get it.

You tried to use a constructor to establish the database connection, but named the method not correctly.

__constructor(...) should be __construct(...), otherwise your constructor will never be called.
Because your class never called the constructor, it tries to use a default connection.


That was it!! Thank you very much. I copied the __construct(or) code from another file which I thought was working. Anyway, now it makes sense why it wasn't working.

Thank you again!

Re: Access denied for user 'ODBC'@'localhost'

PostPosted: 11. March 2010 17:00
by Altrea
You're welcome :)

Re: Access denied for user 'ODBC'@'localhost'

PostPosted: 12. March 2010 09:41
by malt_master
Hi,
I am having the same issue. A newbie here also.

What code and where do I add it to solve the ODBC denied issue?

Thanks IA

Malt

Re: Access denied for user 'ODBC'@'localhost'

PostPosted: 12. March 2010 09:47
by Altrea
malt_master wrote:Hi,
I am having the same issue. A newbie here also.

What code and where do I add it to solve the ODBC denied issue?

Thanks IA

Malt


This problem can have many many different reasons.
To solve your specific problem, you had to give us more details of your code.