- Trending Categories
- Data Structure
- Operating System
- C Programming
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to reset or change the MySQL root password?
152 Lectures 16 hours
87 Lectures 5.5 hours
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.
- 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 to change the password in MongoDB for existing user?
- How to change the local user account password using PowerShell?
- How can we change MySQL user password by using the ALTER USER statement?
- How can we change MySQL user password by using UPDATE statement?
- How to change the root directory of the current process in Python?
- Resetting a Root Password in Linux without External Media
- How to change the root directory of an Apache server on Linux?
- How to reset auto-incrementing column in MySQL?
- Reset AUTO_INCREMENT in MySQL