1 Replies - 300 Views - Last Post: 01 February 2018 - 03:44 AM

#1 DanZman  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 16
  • Joined: 24-January 18

Access denied to my database

Posted 31 January 2018 - 02:05 PM

Hi, I'm using my phpadmin and when I run a basic database connection file, I get the following error; mysqli_connect(): (HY000/1045): Access denied for user 'root'@'localhost' (using password: YES) in C:\xampp\htdocs\DatabaseConnection\dbconnect.php on line 7
Error Access denied for user 'root'@'localhost' (using password: YES);

Here is my connection code
<?php
$host="127.0.0.1";
$port=3306;
$user="root";
$pass ="dbpass";
$dbname="users";
$link = mysqli_connect($host, $user,$pass, $dbname);
if(!$link){
    die("Error ".mysqli_connect_error());
}




I've even went in my config.inc.php and tried putting the password their and it still gives me the same error. I've double checked that I have the password set for this account in the user accounts section in myphpadmin.

Any help would be appreciated.

Is This A Good Question/Topic? 0
  • +

Replies To: Access denied to my database

#2 g00se  Icon User is online

  • D.I.C Lover
  • member icon

Reputation: 3540
  • View blog
  • Posts: 16,132
  • Joined: 20-September 08

Re: Access denied to my database

Posted 01 February 2018 - 03:44 AM

For that to work, you will need to be able to see this when you select from host, user, password from mysql.user

+-----------------------------+------------------+-------------------------------------------+
| host                        | user             | password                                  |
+-----------------------------+------------------+-------------------------------------------+
| localhost                   | root             | *9FB2126F7514B6AF42B20E9E4B8E839B72E31396 |


Note that 'localhost' might not be the same thing as 127.0.0.1. Actually assume they are different. Use 'localhost'

This post has been edited by g00se: 01 February 2018 - 03:45 AM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1