-1

I am getting this error everytime im trying to connect to my database

    Warning: mysqli_connect() [function.mysqli-connect]: (28000/1045): 
Access denied for user 'root'@'name of the computer' (using password: YES) in PATH_TO_FILE on line 8

I checked the privilege and that's what I got

GRANT ALL PRIVILEGES ON *.* TO 'root'@'127.0.0.1' WITH GRANT OPTION

with that command

show GRANTS for "root"@"127.0.0.1" 

Furthermore this is how i connect

$mysqli = mysqli_connect('path to server', 'root', 'gourami',"recherche");

but as you can see the name of the user is not the same in the error message...

I have no idea what is going on, because that should normally work..

I wonder if its my host that is blocked but I had that problem before,but the message wasn't the same. I fixed it with the command.

flush hosts;

But this time it didn't work

Komlan
  • 102
  • 4
  • 12

1 Answers1

4

There shouldn't be a port number in the permissions, it's just user@host. Change the grant to:

GRANT ALL PRIVILEGES ON *.* to root@127.0.0.1
Barmar
  • 741,623
  • 53
  • 500
  • 612
  • 1
    And don't forget to execute 'flush privileges' afterwards. – Niels Keurentjes Apr 16 '13 at 18:34
  • Does the error message actually say `*USER*`, not `root`? Then you need to add permissions for that username, not root. – Barmar Apr 16 '13 at 18:43
  • Actually its says 'root'@'name of the computer' – Komlan Apr 17 '13 at 14:43
  • 2
    Then grant to `root@hostname` instead of 127.0.0.1. MySQL is actually very picky about this, and allows you to set different privileges based on where a user is connecting from. As such always use the exact same identification as he puts in the error, or wildcard to all of them. – Niels Keurentjes Apr 17 '13 at 15:10