Re-enabling localhost privileges in MySQL

I work with XAMPP , and by mistake I removed all privileges for localhost in MySQL, so I cannot use localhost to GRANT ALL PRIVILEGES TO *.* root@localhost , since I do this in localhost . I remember a user with full privileges and his password, but I can’t do much, because localhost has no rights at all and if I use the MYSQL shell, he tells me the same thing

I did not allow remote access when I installed XAMPP , so this could also be a problem (or maybe not, and there is a solution on my machine).

Is there a way to access mysql.user some way, to re-enable privileges for my localhost or to do it using the MySQL shell?

+4
source share
2 answers
  • stop server
  • start the server using the –skip-grant-tables key
  • connect to the server as root without password
  • change privilege table:
      USE mysql;
     UPDATE user SET host = 'localhost' WHERE user = 'root' LIMIT 1;
     FLUSH PRIVILEGES;
    
  • start the server in normal mode
+2
source

If you can restart the MySQL server, follow these steps: How to reset the root password .

+1
source

Source: https://habr.com/ru/post/1439301/


All Articles