Mysql – Change thesql password interactively

MySQLpassword

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.

Best Answer

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.