There are generally 2 method to change MySQL root User password:
I:-Use mysqladmin command to change MySQL root user password.
II:-Using the mysql command to change MySQL root user password.
I:-Use mysqladmin command to change MySQL root user password:
If you haven’t set a root password for MySQL server, then server does not require a password to enter in the root user. To setup root password for first time, use mysqladmin command at shell prompt as shown bellow.
Syntax: mysqladmin -u root password NEWPASSWORD
if you want to change a root password, then you use mysqladmin command
Syntax: mysqladmin -u root -p’oldpassword’ password newpassword
In the above live Example “system@123” is old password and “adcd@123” is new password
II:-Using the mysql command to change MySQL root user password
This is an another method to change MySQL root user password. Generally MySQL store username and password in user table inside the mysql database. whole process to change MySQL root password with mysql command shown bellow figures.
In the above live example changed password is “system@123” and now we access MySQL with this password.