mysqladmin -u root password NEWPASSWORDif you want to change a root with a existing password, you can use this:
mysqladmin -u root -p 'oldpassword' password NEWPASSWORD
Changing MySQL password for non-root user
To change a normal user password you can use the same syntax as changing root with existing password:
mysqladmin -u username -p 'oldpassword' password NEWPASSWORD
Chaning User Password using MySQL command
You can also used the MySQL command line to update user's password, MySQL stores username and passwords in a table inside MySQL database.
- Login to mysql server.
- Use mysql database.
- change password for username by entering: update user set password = PASSWORD("NEWPASSWORD") where user='username';
- Lastly, restore the privileges: flush privileges;