Forums

Give help. Get help.

  • # August 9, 2009 at 11:45 pm

    Hello all. I’m writing today because I’ve got a bit of a problem, and I was hoping your collective brains could help me find where I’ve gone wrong.

    I’m working on a MySQL/PHP based website, to see if I can get beyond the "hello world" stage of my php programming, and my first main obstacle is in my database connection. Before I get to the problem, here’s my tech setup/info:

    • I’m using WAMP for local development[/*:m]
    • I’ve created a new database in PHPMyAdmin called "rie_database" to store my site info[/*:m]
    • I’ve created a user, "rie_admin," with password "xyz" (not really, but the real one is rather complicated)[/*:m]
    • I’ve given "rie_admin" all database specific DATA, STRUCTURE, and ADMINISTRATION privileges, but no globals[/*:m][/list:u]
      I’ve created a simple "config.php" file like so:

      Code:
      < ?php $dbhost = "localhost"; $dbuser = "rie_admin"; $dbpassword = "xyz"; $dbdatabase = "rie_database"; ?>

      which then feeds into the following php:

      Code:
      < ?php $db = mysql_connect($dbhost, $dbuser, $dbpassword) or die(mysql_error()); mysql_select_db($dbdatabase, $db); ?>

      When I try to view the page, I get an error saying:

      Quote:
      Warning: mysql_connect() [function.mysql-connect]: Access denied for user ‘rie_admin’@’localhost’ (using password: YES) in C:wampwwwrie_sitephp_scriptsheader.php on line 7
      Access denied for user ‘rie_admin’@’localhost’ (using password: YES)

      where line 7 is

      Code:
      $db = mysql_connect($dbhost, $dbuser, $dbpassword) or die(mysql_error());

      If, however, I set the config file to

      Code:
      $dbhost = “localhost”;
      $dbuser = “root”;
      $dbpassword = “”;
      $dbdatabase = “rie_database”;

      it connects without any problem.
      Any idea why this is happening? Or even better, how to fix it? I’ve tried giving rie_admin global privileges, with no change in the error. My Google-fu has also failed me. I know I could just keep developing using the root/no password setup, but as this is supposed to be more of an educational/mastering-php/mysql kind of thing, I thought it better to learn what’s going on.

      Thanks in advance for any help.

      P.S., as this is my first post, and I hope to be a contributor as well as a help seeker on this forum, I thought it appropriate to introduce myself. Hi. My name’s Warren.

    # August 10, 2009 at 1:01 pm

    Hi Warren,

    I’m afraid I don’t have any particular answers for you =(. That stuff confuses me too. I do know that that kind of stuff is precicely why I don’t use MAMP (or any of the others) to develop locally. There is too much confusing when then trying to move it live. I’m sure smarter people than us laugh, but whatever. If I develop online, on the same server the real site will be on, I know I won’t have any problems.

    # August 10, 2009 at 6:18 pm

    Hi Warren, sounds like a real tough one. Only thing I can suggest is to (using mysql console):

    Code:
    SHOW GRANTS FOR ‘rie_admin’@’localhost’;
    | GRANT USAGE ON *.* TO ‘rie_admin’@’localhost’ IDENTIFIED BY PASSWORD ‘*xxxxxxx’ |
    | GRANT ALL PRIVILEGES ON `xxz.* TO ‘rie_admin’@’localhost’

    There should be a minimum of GRANT USAGE and also a grant on the specific database. This might at least give you some insight as to why it’s not working.

    Hope that at least points you in the right direction.

    Cheers
    Dave

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.

icon-anchoricon-closeicon-emailicon-linkicon-logo-staricon-menuicon-nav-guideicon-searchicon-staricon-tag