Changing a mysql user password from bash

You can do with the mysql command line program:

Suppose you have a user named freddywilson7, and that his current password is ‘blackberry’. You wish to change it to a more secure password like ’20#zLlDmFUDIR4Wzt$Ag*cef^mG8IZX5pg8xfzg&0#$ge’

You do the following:

$mysql -u root -h localhost -prootpass7
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2015
Server version: 5.5.30-1~dotdeb.0 (Debian)

Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> SET PASSWORD FOR 'freddywilson7'@'localhost' = PASSWORD('mJ7msmwb0lk%*BAIKCA!hT!Xdr3K');
Query OK, 0 rows affected (0.00 sec)

That’s it.

I used this to manually set a stronger password for my WordPress databases, as i-mscp did not allow me to use special characters as part of the password.