Home > Blockchain >  Access denied for user 'root'@'localhost' when connecting to mysql
Access denied for user 'root'@'localhost' when connecting to mysql

Time:11-19

I have been researching this for close to 4 hours but still, I can't connect my Invision Community 4 forum to my mysql ran on localhost with xampp.

I can connect from the shell, but I can't connect to it from elsewhere.

Access denied for user 'root'@'localhost'

CodePudding user response:

I think that remote root access is disabled by default. Run this SQL command via the shell:

GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'password' WITH GRANT OPTION; FLUSH PRIVILEGES;

CodePudding user response:

Most likely you don't have the other "IPs" (like localhost) defined. Follow these steps to fix it:

  1. Execute this query: SELECT `Host`, `Password` FROM `mysql`.`user` WHERE USER = 'root';
  2. Check results, in this example the pc host has no password:
Host Password
localhost *81F5E21E35407D000A6CD4A731AEBFB6AF209E1B
pc
127.0.0.1 *81F5E21E35407D000A6CD4A731AEBFB6AF209E1B
% *81F5E21E35407D000A6CD4A731AEBFB6AF209E1B
  1. Check how are you connected: SELECT CURRENT_USER();:
CURRENT_USER()
root@localhost
  1. Now you know how you are connected and if all the user/host pairs share the same password or not, and maybe update the one that you want to change.
  • Related