Jump to content

database connection failed: Access denied for user ''@'localhost' (using password: NO) (1045)


ronc0011

Recommended Posts

The deal is I know for fact the username and password are good. BTW I’m doing all this on my laptop. Apache, MySQL, & PHP are all installed and running locally.
 
I have a DB named “users” that I created under the root user account with a password of “r00t” now I can run a “SELECT * FROM “ with those credentials using the command line tool that ships with MySQL no problem it show all records in the users table. But the PHP script throws this error

Edited by mac_gyver
fixed font usage
Link to comment
Share on other sites

<?php

   $dbhost = "localhost";
   $dbuser = "root";
   $dbpass = "r00";
   $dbname = "users";
   $conn = mysqli_connect ($host, $user, $pass, $name);

// Test if connection occured This is where we do our error trapping
   
   if(mysqli_connect_errno()) {
     die ("database connection failed: " .
      mysqli_connect_error() .
      " (" . mysqli_connect_errno() . ")"
     );
}
?>

OK, this is what I got and I think you'll be able to see I do have a user name and password...

 

 

 

 

 

Edited by ronc0011
Link to comment
Share on other sites

Well I guess I feel pretty dumb. Just too long staring at this stuff. Also different environment than what I was used to . I changed from a desktop with dual monitors to a laptop with a single 15” monitor. I’m actually used to being able to see what I’m doing. Well thank you for your help. That’s what I needed was a pair of good eyes.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.