- This topic is empty.
August 9, 2009 at 11:45 pm #25677WCMillerMember
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:
August 10, 2009 at 1:01 pm #62002Chris CoyierKeymaster
- 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:
which then feeds into the following php:Code:
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 isCode:$db = mysql_connect($dbhost, $dbuser, $dbpassword) or die(mysql_error());
If, however, I set the config file toCode:$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.
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 #62028davesgonebananasMember
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.
- The forum ‘Back End’ is closed to new topics and replies.