Is it possible to change the user password in mysql in an interactive mode like it one can do in PostgreSQL for example using \password command? My goal is not to provide the new password together with the command like it is described in mysql documentation about how to change the user password.


From the mysqladmin documentation:

In MySQL 5.6, the new password can be omitted following the password command. In this case, mysqladmin prompts for the password value, which enables you to avoid specifying the password on the command line. Omitting the password value should be done only if password is the final command on the mysqladmin command line. Otherwise, the next argument is taken as the password.

In earlier versions you can't do this as those will complain for 'Too few arguments to change password' (thanks Kaarel for reporting this). In theory you can issue a command like

mysqladmin -u kaarel password newpass

and then it does not appear in the database logs - but may still be stored elsewhere, like .bash_history.

  • In mysql v 5.1 if I omit the newpass, it complains: mysqladmin: Too few arguments to change password – Kaarel Sep 3 '13 at 13:22
  • It would be nice to have an example of the new syntax in the answer. (Something like mysqladmin -u myname [-p] password seems to do the trick. I get prompted for my old password (if I add -p), then prompted for the new password twice.) – mwfearnley Nov 20 '16 at 12:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.