To encrypt mysql password use mysql_config_editor. Program will create file .mylogin.cnf which is recognize by mysql.
Example of command:
[mantonik@web2 ~]$ mysql_config_editor set --login-path=mariusz.12 --user=mariusz --host=10.2.5.12 -p
Enter password:
Dispaly list of all login paths
[mantonik@web2 ~]$ mysql_config_editor print --all
[client]
[backup]
user = bkuser
password = *****
host = 10.2.5.12
[mariusz.11]
user = mariusz
password = *****
host = 10.2.5.11
[mariusz.12]
user = mariusz
password = *****
host = 10.2.5.12
Example of command:
[mantonik@web2 ~]$ mysql_config_editor set --login-path=mariusz.12 --user=mariusz --host=10.2.5.12 -p
Enter password:
Dispaly list of all login paths
[mantonik@web2 ~]$ mysql_config_editor print --all
[client]
[backup]
user = bkuser
password = *****
host = 10.2.5.12
[mariusz.11]
user = mariusz
password = *****
host = 10.2.5.11
[mariusz.12]
user = mariusz
password = *****
host = 10.2.5.12
More informaiton abount this function you can find in mysql documentation