FeralReason Posted April 24, 2009 Share Posted April 24, 2009 I am a newbie to mysql, 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 ? Quote Link to comment https://forums.phpfreaks.com/topic/155463-solved-trying-to-access-mysql-db-through-php-access-denied-err-1045/ Share on other sites More sharing options...
PFMaBiSmAd Posted April 24, 2009 Share Posted April 24, 2009 That's actually the error when the user does not have privileges to access that database (a connection error message is different.) You need to execuite the fillowing to actually cause the previleges to take effect (note the Grant = NO value for the user you created) - FLUSH PRIVILEGES Quote Link to comment https://forums.phpfreaks.com/topic/155463-solved-trying-to-access-mysql-db-through-php-access-denied-err-1045/#findComment-818076 Share on other sites More sharing options...
FeralReason Posted May 17, 2009 Author Share Posted May 17, 2009 Thanks for the response. Had a typo (misspelled username) -- dumb mistake. Thanx for your help. Quote Link to comment https://forums.phpfreaks.com/topic/155463-solved-trying-to-access-mysql-db-through-php-access-denied-err-1045/#findComment-836018 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.