Trying to Access MySQL Through PHP -- Access denied

Problems with the Windows version of XAMPP, questions, comments, and anything related.

Trying to Access MySQL Through PHP -- Access denied

Postby FeralReason » 24. April 2009 05:22

I am running an XAMPP stack on Windows XP as a test environment and am trying to make my first connection to a mysql database using a connection script in "Sams Teach Yourself PHP, MySQL and Apache" by Julie Meloni. I successfully built the database, created the user and confirmed the user's existance by looking under the "privileges" tab in phpMyAdmin, where I saw this:

Users having access to "testDB":
User Host Type Privileges Grant Action
jouser localhost database-specific ALL PRIVILEGES No
root 127.0.0.1 global ALL PRIVILEGES Yes
root localhost global ALL PRIVILEGES Yes

Next I ran the script below:

<?php
$mysqli = new mysqli("localhost","jouser","somepass","testDB");

if(mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
} else {
printf("host information: %s\n", mysqli_get_host_info($mysqli));
}
?>

And then got this error:

Warning: mysqli::mysqli() [mysqli.mysqli]: (28000/1045): Access denied for user 'joeuser'@'localhost' (using password: YES) in C:\xampp\htdocs\mysqlconnect.php on line 2
Connect failed: Access denied for user 'joeuser'@'localhost' (using password: YES)

Although the author explains that this is the error you get if the connection fails, she provides no clue as to how to troubleshoot this.

Can anyone give me some help ?
FeralReason
 
Posts: 17
Joined: 16. April 2009 20:42

Re: Trying to Access MySQL Through PHP -- Access denied

Postby Wiedmann » 24. April 2009 07:24

Warning: mysqli::mysqli() [mysqli.mysqli]: (28000/1045): Access denied for user 'joeuser'@'localhost' (using password: YES) in C:\xampp\htdocs\mysqlconnect.php on line 2
Connect failed: Access denied for user 'joeuser'@'localhost' (using password: YES)

Did you have a user with the name "joeuser" and the password "testDB" in MySQL?

(The users/pass from a new XAMPP installation you can see in readme_en.txt".)
Wiedmann
AF Moderator
 
Posts: 17106
Joined: 01. February 2004 12:38
Location: Stuttgart / Germany

Re: Trying to Access MySQL Through PHP -- Access denied

Postby Nobbie » 24. April 2009 09:40

Did you *really* copy & paste as well the script as the error message into your post? No, you didnt. Please copy & paste, and dont type into the post, as you add severe typos.

If the error message is copied, you obviously supplied a wrong username, "joeuser" instead of "jouser". But in the script you show us, you supplied "jouser" - that does not match the error message!
Nobbie
 
Posts: 8769
Joined: 09. March 2008 13:04

Re: Trying to Access MySQL Through PHP -- Access denied

Postby FeralReason » 24. April 2009 13:05

You're right, I confess. I changed the user name and password back to the one in the author's script. Sorry. I take it you have not seen this problem before ?

Any help would be appreciated !

Glenn
FeralReason
 
Posts: 17
Joined: 16. April 2009 20:42

Re: Trying to Access MySQL Through PHP -- Access denied

Postby Nobbie » 24. April 2009 14:07

>I take it you have not seen this problem before ?

I still cannot see if there is really a problem with MySQL of if you simply supplied an invalid username. Still please copy & paste the script, the error message and the output of phpmyadmin.
Nobbie
 
Posts: 8769
Joined: 09. March 2008 13:04

Re: Trying to Access MySQL Through PHP -- Access denied

Postby FeralReason » 24. April 2009 14:30

Nobbie -- you were on the right track the first time. I mistyped the user name that I had in the DB and somehow the other user account I had created was screwed up (I still don't know why) so, obviously, I did not connect. Created a new DB this morning and connected without difficulty and then created a new user in the same DB and connected without difficulty. Real lame mistake ! :oops:

Thanks for your help.
FeralReason
 
Posts: 17
Joined: 16. April 2009 20:42


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 79 guests