How to change MySQL user password from command line using mysqladmin on Linux
Apart of the MySQL command line interface a a system administrator is able to change MySQL user's password using mysqladmin command directly from a shell command line. The following linux command will change/update a current MySQL root password given that current password is blank:
# mysqladmin -u root password 'newpass'
The above command will change MySQL root's password to newpass. To change MySQL root's password to abc123 where that current password is set to newpass we need to use -p option which allows us to supply the mysqladmin command with a current user password. For example:
# mysqladmin -u root -pnewpass password 'abc123'
Test the new password:
# mysqladmin -u root -pabc123 ping
mysqld is alive
Please note the deliberate lack of space between -p option and current user password. The above method can be used to change password for any other user.