How to remove MySQL root password

The Question :

206 people think this question is useful

I want to remove the password for user root in localhost. How can I do that? By mistake I have set the password of root user. That’s why phpmyadmin is giving an error:

#1045 - Access denied for user 'root'@'localhost' (using password: NO)

The Question Comments :
  • Why not configure your phpMyAdmin to use the root password instead?
  • The MySQL documentation contains instructions on how to reset the root password in case you have forgotten it.
  • Note that starting with MySQL 5.7, a random root password is set by default, and you cannot remove it without disabling the validate_password plugin first. See my article Removing the MySQL root password or this gist directly.
  • For all non-root users SET PASSWORD FOR root@`%`=PASSWORD(''); , the percentage sign must be enclosed by the backticks

The Answer 1

387 people think this answer is useful

You need to set the password for root@localhost to be blank. There are two ways:

  1. The MySQL SET PASSWORD command:

    SET PASSWORD FOR root@localhost=PASSWORD('');
  2. Using the command-line mysqladmin tool:

    mysqladmin -u root -pType_in_your_current_password_here password ''

The Answer 2

25 people think this answer is useful

I have also been through this problem,

First i tried setting my password of root to blank using command :

SET PASSWORD FOR root@localhost=PASSWORD('');

But don’t be happy , PHPMYADMIN uses not localhost , i know you would say both are same but that is not the case , use the command mentioned underneath and you are done.


Just replace localhost with and you are done .

Add a Comment