
- Learn MySQL
- MySQL - Home
- MySQL - Introduction
- MySQL - Installation
- MySQL - Administration
- MySQL - PHP Syntax
- MySQL - Connection
- MySQL - Create Database
- MySQL - Drop Database
- MySQL - Select Database
- MySQL - Data Types
- MySQL - Create Tables
- MySQL - Drop Tables
- MySQL - Insert Query
- MySQL - Select Query
- MySQL - Where Clause
- MySQL - Update Query
- MySQL - Delete Query
- MySQL - Like Clause
- MySQL - Sorting Results
- MySQL - Using Join
- MySQL - NULL Values
- MySQL - Regexps
- MySQL - Transactions
- MySQL - Alter Command
- MySQL - Indexes
- MySQL - Temporary Tables
- MySQL - Clone Tables
- MySQL - Database Info
- MySQL - Using Sequences
- MySQL - Handling Duplicates
- MySQL - SQL Injection
- MySQL - Database Export
- MySQL - Database Import
How to reset or change the MySQL root password?
To reset or change the root password, first we need to open MySQL in the Administrator mode. There, we can see all the users as well as the host. The following is the query −
mysql> USE mysql; Database changed mysql> SELECT user,host from user;
Here is the output.
+------------------+-----------+ | user | host | +------------------+-----------+ | John | % | | Mac | % | | Manish | % | | mysql.infoschema | % | | mysql.session | % | | mysql.sys | % | | root | % | | am | localhost | +------------------+-----------+ 8 rows in set (0.00 sec)
Now, let us see the query to change the password.
mysql> ALTER USER 'root'@'%' IDENTIFIED BY '123456'; Query OK, 0 rows affected (0.13 sec) mysql> ALTER USER 'Manish'@'%' IDENTIFIED BY '123456'; Query OK, 0 rows affected (0.14 sec)
As you saw above, ‘Manish’ is a root and we have altered the password. The above query works in MySQL 5.7.6 and higher versions.
To check if the password is reset or changed, we need to open the CMD and reach the directory in the system where the bin is present. Let us first try to login with the old password.

As you can see in the above screenshot, the previous password that has been reset or changed is tried. The same won’t work. Now, we will try to open MySQL with the new password i.e ‘123456’ and it works.

- Related Articles
- Reset the root user password on rhel7 xcentos7 x
- Reset Kali Linux Password
- How can we change MySQL user password by using the SET PASSWORD statement?
- How can I change root username in MySQL?
- How can we change MySQL user password by using UPDATE statement?
- How can we change MySQL user password by using the ALTER USER statement?
- How to change password of users in Django?
- How to change the password in MongoDB for existing user?
- How to change the local user account password using PowerShell?
- How to reset auto-incrementing column in MySQL?
- How to create or reset counters with JavaScript?
- How to reset the primary key of a table in mysql?
- How to reset or clear a form using JavaScript?
- Reset MySQL field to default value?
- Reset AUTO_INCREMENT in MySQL
