If mysql -u root works but mysql -h your_hostname-u root results in Access denied (where your_hostname is the actual host name of the local host), you may not have the correct name for your host in the user table.
I am getting this error everytime im trying to connect to my database Warning: mysqliconnect function.mysqli-connect: : Access denied for user 'root'@'name of the computer' (using password: YES) in PATHTOFILE 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 = mysqliconnect('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 The database is in another server, before everything was working but now for some reason I cant connect.